You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2023/08/28 10:17:04 UTC
[GitHub] [airflow] Taragolis commented on a diff in pull request #33821: Use Literal from airflow.typing_compat in Airflow core
Taragolis commented on code in PR #33821:
URL: https://github.com/apache/airflow/pull/33821#discussion_r1307234109
##########
airflow/typing_compat.py:
##########
@@ -31,8 +31,14 @@
from typing import Protocol, TypedDict, runtime_checkable
# Literal from typing module has various issues in different Python versions, see:
-# https://typing-extensions.readthedocs.io/en/latest/#Literal
-from typing_extensions import Literal
+# - https://typing-extensions.readthedocs.io/en/latest/#Literal
+# - bpo-45679: https://github.com/python/cpython/pull/29334
+# - bpo-42345: https://github.com/python/cpython/pull/23294
+# - bpo-42345: https://github.com/python/cpython/pull/23383
+if sys.version_info >= (3, 10, 1) or (3, 9, 8) <= sys.version_info < (3, 10):
+ from typing import Literal
+else:
+ from typing_extensions import Literal # type: ignore[assignment]
Review Comment:
Without `type: ignore[assignment]` mypy complains about type assigments
```console
airflow/typing_compat.py:41: error: Incompatible import of "Literal" (imported
name has type "typing_extensions._SpecialForm", local name has type
"<typing special form>") [assignment]
from typing_extensions import Literal
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)
```
Another fix: set condition to `if sys.version_info >= (3, 11):`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org