Skip to content

Always use Literal from typing_extensions - #33794

Merged
Taragolis merged 1 commit into
apache:mainfrom
Taragolis:literal-from-typing-extensions
Aug 27, 2023
Merged

Always use Literal from typing_extensions#33794
Taragolis merged 1 commit into
apache:mainfrom
Taragolis:literal-from-typing-extensions

Conversation

@Taragolis

Copy link
Copy Markdown
Contributor

During the removing support of Python 3.7 #30963, we incidentally create this block

# Literal in 3.8 is limited to one single argument, not e.g. "Literal[1, 2]".ifsys.version_info>= (3, 9):
fromtypingimportLiteralelse:
fromtypingimportLiteral

This PR fix by use everywhere from typing_extension import Literal instead of

  • from typing import Literal
  • from airflow.typing_compat import Literal

In additional Literal has other known bugs which finally resolved in Python 3.10.1+, so personally I thought that better just use from typing_extension import Literal rather than out airflow.typing_compat resolver


^ 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 threadairflow/models/taskinstance.py Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

TypeGuard also presented in our airflow.typing_compat so we might want to use two imports here:

fromtyping_extensionsimportLiteralfromairflow.typing_compatimportTypeGuard

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes.

@Taragolis
Taragolisforce-pushed the literal-from-typing-extensions branch 2 times, most recently from ed9d450 to cc1ffc2CompareAugust 27, 2023 19:48
@Taragolis
Taragolisforce-pushed the literal-from-typing-extensions branch from cc1ffc2 to 7fec822CompareAugust 27, 2023 19:57
@Taragolis

Copy link
Copy Markdown
ContributorAuthor

I hope I've finally finish rebasing and resolve conflicts 🤣

@hussein-awala

Copy link
Copy Markdown
Member

I hope I've finally finish rebasing and resolve conflicts 🤣

I will wait your PR before merging the other PRs

@Taragolis

Copy link
Copy Markdown
ContributorAuthor

No problem, that was just funny.
Anyway someone should resolve conflict - I in one PR or you in multiple

@hussein-awala

Copy link
Copy Markdown
Member

Flaky test, you can merge it if there is nothing to change.

@Taragolis
Taragolis merged commit cede385 into apache:mainAug 27, 2023
@Taragolis
Taragolis deleted the literal-from-typing-extensions branch August 27, 2023 21:26
@uranusjr

Copy link
Copy Markdown
Member

Why is typing_extension used unconditionally instead of only for 3.10.1+ (or more conveniently just 3.11+)?

@Taragolis

Copy link
Copy Markdown
ContributorAuthor

Why is typing_extension used unconditionally instead of only for 3.10.1+ (or more conveniently just 3.11+)?

For provider just for do not write something this condition everywhere, seem like we save to use until we can get rid of it.

For core, maybe here we should use such condition, and I was merge before got additional review comments 😞

@uranusjr

Copy link
Copy Markdown
Member

Should I do that? (Asking in case you’re already doing it)

@Taragolis

Copy link
Copy Markdown
ContributorAuthor

I could do that.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLIarea:dev-toolsarea:providersprovider:amazonAWS/Amazon - related issuesprovider:cncf-kubernetesKubernetes (k8s) provider related issuesprovider:mongoprovider:salesforcetype:bug-fixChangelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Taragolis@hussein-awala@uranusjr@potiuk