Skip to content

Sync typeshed #13386

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

Merged
merged 3 commits into from
Aug 19, 2022
Merged

Sync typeshed #13386

merged 3 commits into from
Aug 19, 2022

Conversation

jhance
Copy link
Collaborator

@jhance jhance commented Aug 11, 2022

Source commit:
python/typeshed@a92da58

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

AlexWaygood commented Aug 11, 2022

The psycopg primer errors are because of python/typeshed#8446 — the maintainer has been warned, and said he was cool with it.

For most of the other primer errors, I think you need to reapply #13093.

Fixes #13091

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
@github-actions

This comment has been minimized.

@jhance
Copy link
Collaborator Author

jhance commented Aug 17, 2022

@sobolevn Do you have any ideas what is going on in stubtest?

@sobolevn
Copy link
Member

test_module.pyi:89: error: "Match" expects no type arguments, but 1 given

I suspect that this test fails:

yield Case(
stub="""
from typing import Match
M = Match[str]
""",
runtime="""
from typing import Match
M = Match[str]
""",
error=None,
)

Why? I have no idea. Probably due to some typeshed changes. I think @AlexWaygood was working with Match recently.

@AlexWaygood
Copy link
Member

Why? I have no idea. Probably due to some typeshed changes. I think @AlexWaygood was working with Match recently.

Yeah, I'm 99% sure this is somehow due to a typeshed change I made recently. I'll try to take a look sometime soon and suggest a fix!

@AlexWaygood
Copy link
Member

The major change to re in this typeshed sync is python/typeshed@ea7bbbd. But I can't figure out why this is making teststubtest think that re.Match expects no type arguments. @hauntsaninja, do you have any ideas? :)

The problematic line in the test is not actually the one @sobolevn suggested; it is this one:

MMM = re.Match[str]

If you comment out that line, the test passes fine.

@AlexWaygood
Copy link
Member

The major change to re in this typeshed sync is python/typeshed@ea7bbbd. But I can't figure out why this is making teststubtest think that re.Match expects no type arguments. @hauntsaninja, do you have any ideas? :)

The problematic line in the test is not actually the one @sobolevn suggested; it is this one:

MMM = re.Match[str]

If you comment out that line, the test passes fine.

I figured it out. re now imports AnyStr from typing, but AnyStr wasn't defined in teststubtest's typing fixture. If you merge #13447 into this branch, the CI should go green :)

@hauntsaninja
Copy link
Collaborator

Thanks for figuring it out! In general, weird errors in mypy tests are 90% fixture related issues

@github-actions
Copy link
Contributor

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

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: error: Unused "type: ignore" comment
+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: note: Error code "valid-type" not covered by "type: ignore" comment
+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:65: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:65: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:72: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:72: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: error: Unused "type: ignore" comment
+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: note: Error code "valid-type" not covered by "type: ignore" comment
+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:136: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:136: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:161: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:161: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:185: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:185: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:186: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:186: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:187: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:187: note: Perhaps you need "Callable[...]" or a callback protocol?
+ psycopg/psycopg/pq/_pq_ctypes.pyi:189: error: Function "ctypes.pointer" is not valid as a type  [valid-type]
+ psycopg/psycopg/pq/_pq_ctypes.pyi:189: note: Perhaps you need "Callable[...]" or a callback protocol?

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/client.py:125: error: Argument 1 to "asynccontextmanager" has incompatible type "Callable[[Any], ContextManager[None]]"; expected "Callable[[Any], AsyncIterator[<nothing>]]"
+ src/prefect/client.py:125: error: Argument 1 to "asynccontextmanager" has incompatible type "Callable[[Any], AbstractContextManager[None]]"; expected "Callable[[Any], AsyncIterator[<nothing>]]"
- src/prefect/context.py:520: error: Incompatible types in assignment (expression has type "None", variable has type "ContextManager[PrefectObjectRegistry]")
+ src/prefect/context.py:520: error: Incompatible types in assignment (expression has type "None", variable has type "AbstractContextManager[PrefectObjectRegistry]")

pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/vendor/decorator.py:279: error: Module "contextlib" has no attribute "GeneratorContextManager"; maybe "_GeneratorContextManager", "_AsyncGeneratorContextManager", or "ContextManager"?
+ pyinstrument/vendor/decorator.py:279: error: Module "contextlib" has no attribute "GeneratorContextManager"; maybe "_GeneratorContextManager", "_AsyncGeneratorContextManager", or "AbstractContextManager"?

@hauntsaninja hauntsaninja merged commit bf143d9 into master Aug 19, 2022
@hauntsaninja hauntsaninja deleted the jhance-typeshed branch August 19, 2022 05:38
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.

5 participants