Sync typeshed
Source commit: https://github.com/python/typeshed/commit/a92da58328aa259184ff45bb7408e82426fb563e
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/filesystems.py:282: error: Unsupported operand types for + ("str" and "TextIOWrapper")
- src/prefect/filesystems.py:284: error: Unsupported operand types for + ("str" and "TextIOWrapper")
+ src/prefect/filesystems.py:282: error: No overload variant of "__add__" of "str" matches argument type "TextIOWrapper"
+ src/prefect/filesystems.py:282: note: Possible overload variants:
+ src/prefect/filesystems.py:282: note: def __add__(self, str) -> str
+ src/prefect/filesystems.py:284: error: No overload variant of "__add__" of "str" matches argument type "TextIOWrapper"
+ src/prefect/filesystems.py:284: note: Possible overload variants:
+ src/prefect/filesystems.py:284: note: def __add__(self, str) -> str
- 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]")
porcupine (https://github.com/Akuli/porcupine)
+ porcupine/plugins/editorconfig.py:152: error: Argument 1 to "map" has incompatible type "Callable[[AnyStr], AnyStr]"; expected "Callable[[str], AnyStr]" [arg-type]
+ porcupine/plugins/pluginmanager.py:133: error: Argument 1 to "map" has incompatible type "Callable[[AnyStr], AnyStr]"; expected "Callable[[str], AnyStr]" [arg-type]
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"?
core (https://github.com/home-assistant/core)
+ homeassistant/components/sonos/media.py:180: error: List item 0 has incompatible type "Optional[str]"; expected "None" [list-item]
streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/runtime/legacy_caching/hashing_test.py:257:30: error: Unsupported operand types for + ("str" and "int") [operator]
+ lib/tests/streamlit/runtime/legacy_caching/hashing_test.py:257:24: error: No overload variant of "__add__" of "str" matches argument type "int" [operator]
+ lib/tests/streamlit/runtime/legacy_caching/hashing_test.py:257:24: note: Possible overload variants:
+ lib/tests/streamlit/runtime/legacy_caching/hashing_test.py:257:24: note: def __add__(self, str) -> str
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/multipart.py:95: error: Argument 1 to "map" has incompatible type "Callable[[AnyStr], AnyStr]"; expected "Callable[[str], AnyStr]" [arg-type]
The psycopg primer errors are because of https://github.com/python/typeshed/pull/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 https://github.com/python/mypy/pull/13093.
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:126: error: Argument 1 to "asynccontextmanager" has incompatible type "Callable[[Any], ContextManager[None]]"; expected "Callable[[Any], AsyncIterator[<nothing>]]"
+ src/prefect/client.py:126: 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"?
@sobolevn Do you have any ideas what is going on in stubtest?
test_module.pyi:89: error: "Match" expects no type arguments, but 1 given
I suspect that this test fails: https://github.com/python/mypy/blob/487b736743637142a53e49525b935ccad5ccc5fd/mypy/test/teststubtest.py#L846-L856
Why? I have no idea. Probably due to some typeshed changes. I think @AlexWaygood was working with Match recently.
Why? I have no idea. Probably due to some typeshed changes. I think @AlexWaygood was working with
Matchrecently.
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!
The major change to re in this typeshed sync is https://github.com/python/typeshed/commit/ea7bbbdad7abf05a3bd3feb25eef93b53165e2d9. 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: https://github.com/python/mypy/blob/3ec1849528bd9ae8fb744620cfa24705ee7d39b0/mypy/test/teststubtest.py#L903
If you comment out that line, the test passes fine.
The major change to
rein this typeshed sync is python/typeshed@ea7bbbd. But I can't figure out why this is makingteststubtestthink thatre.Matchexpects 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:
https://github.com/python/mypy/blob/3ec1849528bd9ae8fb744620cfa24705ee7d39b0/mypy/test/teststubtest.py#L903
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 :)
Thanks for figuring it out! In general, weird errors in mypy tests are 90% fixture related issues
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"?