Skip to content

Sync typeshed #12982

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 2 commits into from
Jul 8, 2022
Merged

Sync typeshed #12982

merged 2 commits into from
Jul 8, 2022

Conversation

hauntsaninja
Copy link
Collaborator

Source commit:
python/typeshed@91d6383

hauntsaninja added 2 commits June 14, 2022 13:15
@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:

boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/cli.py:29: error: Argument 1 to "run" has incompatible type "Awaitable[T]"; expected "Coroutine[Any, Any, <nothing>]"

anyio (https://github.com/agronholm/anyio)
+ src/anyio/_backends/_asyncio.py:89: error: Unused "type: ignore" comment

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/logging.py:80: error: Unused "type: ignore" comment
+ sphinx/util/logging.py:434: error: Unused "type: ignore" comment

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/debug/repr.py:134: error: Unused "type: ignore" comment

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]

manticore (https://github.com/trailofbits/manticore)
+ manticore/core/workspace.py:220: error: Argument 1 to "exists" has incompatible type "Optional[str]"; expected "Union[Union[str, bytes, PathLike[str], PathLike[bytes]], int]"
+ manticore/core/workspace.py:221: error: Argument 1 to "isdir" has incompatible type "Optional[str]"; expected "Union[Union[str, bytes, PathLike[str], PathLike[bytes]], int]"
+ manticore/core/workspace.py:223: error: Argument 1 to "mkdir" has incompatible type "Optional[str]"; expected "Union[str, bytes, PathLike[str], PathLike[bytes]]"

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]

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/legacy_caching/hashing_test.py:253:30: error: Unsupported operand types for + ("str" and "int")  [operator]
+ lib/tests/streamlit/legacy_caching/hashing_test.py:253:24: error: No overload variant of "__add__" of "str" matches argument type "int"  [operator]
+ lib/tests/streamlit/legacy_caching/hashing_test.py:253:24: note: Possible overload variants:
+ lib/tests/streamlit/legacy_caching/hashing_test.py:253:24: note:     def __add__(self, str) -> str

optuna (https://github.com/optuna/optuna)
+ tests/samplers_tests/tpe_tests/test_sampler.py:1116: error: Incompatible types in assignment (expression has type "DictProxy[Any, Any]", variable has type "Dict[int, List[int]]")
+ tests/samplers_tests/tpe_tests/test_sampler.py:1117: error: Incompatible types in assignment (expression has type "DictProxy[Any, Any]", variable has type "Dict[int, int]")

@ilevkivskyi
Copy link
Member

@hauntsaninja We want to use this sync for internal mypy release. Could you please check the output of mypy_primer, are the new errors correct/reasonable? Especially the one with AnyStr (I wanted to check myself, but may not have time today).

@hauntsaninja
Copy link
Collaborator Author

The ones in aiohttp / homeassistant (core) are false positives:
python/typeshed#7725 (comment)
Pretty sure this is also what's causing the porcupine examples (although weirdly it doesn't show up in primer on the typeshed PR and porcupine hasn't made any recent changes)

boostedblob change looks intentional:
python/typeshed#7844

manticore is also a false positive, but hard to fix:
python/typeshed#7939 (comment)

streamlit is just a change in diagnostics

The one in optuna is intentional (although not sure that I'd have made the same change):
python/typeshed#7938

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Jun 16, 2022

Since we don't have proper support for LiteralString, python/typeshed#7725 doesn't get us anything. If it's blocking a release, you could temporarily revert that in our vendored copy.

Here are minimal reproducers:

from typing import Any, AnyStr

def escape(pattern: AnyStr) -> AnyStr: ...
CHAR: set[str] = {"x"}
"".join(map(escape, CHAR))

def sonos(channel: str | None, radio_show: Any):
    " • ".join(filter(None, [channel, radio_show]))

Probably change is breaking type context

@AlexWaygood
Copy link
Member

FYI you might want to cherry-pick python/typeshed#8137 after merging this, since this sync contains the following regression: python/typeshed#8136.

@ilevkivskyi
Copy link
Member

I am going to merge this PR as is, and will separately fix small issues/regressions in separate PRs.

@ilevkivskyi ilevkivskyi merged commit 7a6ecd3 into python:master Jul 8, 2022
@hauntsaninja hauntsaninja deleted the sync branch July 8, 2022 17:25
Gobot1234 pushed a commit to Gobot1234/mypy that referenced this pull request Aug 12, 2022
* Sync typeshed

Source commit:
python/typeshed@91d6383

* fix tests

Co-authored-by: hauntsaninja <>
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.

3 participants