Skip to content

Correctly handle variadic instances with empty arguments#16238

Merged
ilevkivskyi merged 4 commits intopython:masterfrom
ilevkivskyi:fix-zero-args-tvt
Oct 16, 2023
Merged

Correctly handle variadic instances with empty arguments#16238
ilevkivskyi merged 4 commits intopython:masterfrom
ilevkivskyi:fix-zero-args-tvt

Conversation

@ilevkivskyi
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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