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

Bump typing-extensions and mypy for ParamSpec #25088

Merged
merged 11 commits into from
Jul 18, 2022

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Jul 15, 2022

I want to use them in some @task signature improvements. Mypy added this in 0.950, but let's just bump to latest since why not.

Changelog of typing-extensions is spotty before 4.0, but ParamSpec was introduced some time before that (likely some time in 2021), and it seems to be a reasonble minimum to bump to.

See PEP 612 for more about ParamSpec if you’re interested. But in short, it solves our problem when typing @task—the resulting task should accept the same arguments as the wrapped function inside, but when called should return an XComArg, instead of the wrapped function’s return value.

# This is a Callable[[int, str], str]
def foo(a: int, b: str) -> str:
    return b * a

# How can we type the wrapped task as Callable[[int, str] XComArg]?
# ParamSpec makes this possible.
@task
def foo(a: int, b: str) -> str:
    return b * a

@potiuk
Copy link
Member

potiuk commented Jul 15, 2022

Nice! Let's see how many errors it will produce to fix though :)

I want to use them in some @task signature improvements. Mypy added this
in 0.950, but let's just bump to latest since why not.

Changelog of typing-extensions is spotty before 4.0, but ParamSpec was
introduced some time before that (likely some time in 2021), and it
seems to be a reasonble minimum to bump to.

For more about ParamSpec, read PEP 612: https://peps.python.org/pep-0612/
@uranusjr
Copy link
Member Author

Run mypy for core......................................................................Failed
- hook id: run-mypy
- exit code: 2
/opt/airflow/airflow/providers/google/cloud/hooks/dataflow.py:541: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 0.961
/opt/airflow/airflow/providers/google/cloud/hooks/dataflow.py:541: : note: please use --show-traceback to print a traceback when reporting a bug
Run mypy for providers.................................................................Failed
- hook id: run-mypy
- exit code: 2
airflow/providers/google/cloud/hooks/dataflow.py:541: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 0.961
airflow/providers/google/cloud/hooks/dataflow.py:541: : note: please use --show-traceback to print a traceback when reporting a bug

Oh no

@uranusjr uranusjr marked this pull request as draft July 17, 2022 07:30
@uranusjr
Copy link
Member Author

uranusjr commented Jul 18, 2022

Alright, the failures are fixed. I am not sure with a lot of the changes I made, so please lend an eye if you could.

@uranusjr uranusjr marked this pull request as ready for review July 18, 2022 05:13
@uranusjr uranusjr requested a review from turbaszek as a code owner July 18, 2022 05:13
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.

NIce!

@potiuk
Copy link
Member

potiuk commented Jul 18, 2022

All looks legit!

@potiuk potiuk merged commit e32e9c5 into apache:main Jul 18, 2022
@uranusjr uranusjr deleted the upgrade-mypy-paramspec branch July 18, 2022 09:53
potiuk pushed a commit that referenced this pull request Jul 21, 2022
* Bump typing-extensions and mypy for ParamSpec

I want to use them in some @task signature improvements. Mypy added this
in 0.950, but let's just bump to latest since why not.

Changelog of typing-extensions is spotty before 4.0, but ParamSpec was
introduced some time before that (likely some time in 2021), and it
seems to be a reasonble minimum to bump to.

For more about ParamSpec, read PEP 612: https://peps.python.org/pep-0612/

(cherry picked from commit e32e9c5)
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Aug 15, 2022
@ephraimbuddy ephraimbuddy added this to the Airflow 2.3.4 milestone Aug 15, 2022
@ephraimbuddy ephraimbuddy added changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) type:misc/internal Changelog: Misc changes that should appear in change log and removed type:misc/internal Changelog: Misc changes that should appear in change log changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) labels Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants