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

Correctly handle variadic instances with empty arguments #16238

Merged
merged 4 commits into from
Oct 16, 2023

Conversation

ilevkivskyi
Copy link
Member

Fixes #16199

It was surprisingly hard to fix, because all possible fixes strongly interfered with the code that makes "no-args" aliases possible:

l = list
x: l[int]  # OK, same as list[int]

So after all I re-organized (and actually simplified) that old code.

@github-actions

This comment has been minimized.

@ilevkivskyi
Copy link
Member Author

Oh wow, it looks like all the errors in the primer are real. Previously we didn't report an error for missing type argument for a generic class if it appeared inside a union in a target of a type alias. I added a regression test.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

schema_salad (https://github.com/common-workflow-language/schema_salad)
+ mypy-stubs/mistune/block_parser.pyi:19: note: In module imported here,
+ mypy-stubs/mistune/markdown.pyi:4: note: ... from here,
+ schema_salad/makedoc.py:36: note: ... from here:
+ mypy-stubs/mistune/scanner.pyi:19:52: error: Missing type parameters for generic type "Match"  [type-arg]

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/job.py:115:65: error: Missing type parameters for generic type "partial"  [type-arg]

websockets (https://github.com/aaugustin/websockets)
+ src/websockets/typing.py:29: error: Missing type parameters for generic type "LoggerAdapter"  [type-arg]

python-chess (https://github.com/niklasf/python-chess)
+ chess/polyglot.py:14: error: Missing type parameters for generic type "PathLike"  [type-arg]

koda-validate (https://github.com/keithasaurus/koda-validate)
+ koda_validate/errors.py:164: error: Missing type parameters for generic type "PredicateErrs"  [type-arg]

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/type_util.py:237:41: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
+ lib/streamlit/type_util.py:237:47: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
+ lib/streamlit/type_util.py:237:53: error: Implicit generic "Any". Use "typing.Set" and specify generic parameters  [type-arg]
+ lib/streamlit/elements/arrow.py:49:5: error: Missing type parameters for generic type "Iterable"  [type-arg]

@ilevkivskyi ilevkivskyi merged commit 85f40b5 into python:master Oct 16, 2023
18 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-zero-args-tvt branch October 16, 2023 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zero-long TypeVarTuple special case doesn't work
1 participant