Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Literal from airflow.typing_compat in Airflow core #33821

Merged
merged 1 commit into from Sep 1, 2023

Conversation

Taragolis
Copy link
Contributor

Resolve: #33794 (comment)


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Comment on lines +38 to +41
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]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without type: ignore[assignment] mypy complains about type assigments

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):

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Taragolis Taragolis merged commit ec45d42 into apache:main Sep 1, 2023
42 checks passed
@Taragolis Taragolis deleted the conditional-usage-literal-in-core branch September 1, 2023 08:30
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.2 milestone Oct 3, 2023
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants