Merged
Conversation
Source commit: python/typeshed@37a180e
This is allegedly causing large performance problems, see 13821 typeshed/8231 had zero hits on mypy_primer, so it's not the worst thing to undo. Patching this in typeshed also feels weird, since there's a more general soundness issue. If a typevar has a bound or constraint, we might not want to solve it to a Literal. If we can confirm the performance regression or fix the unsoundness within mypy, I might pursue upstreaming this in typeshed. (Reminder: add this to the sync_typeshed script once merged)
Since the plugin provides superior type checking: python#13987 (comment)
hauntsaninja
approved these changes
Feb 3, 2023
Collaborator
hauntsaninja
left a comment
There was a problem hiding this comment.
Looks great, thank you for doing this!
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
+ src/pip/_internal/metadata/_json.py:67: error: Item "None" of "Optional[List[Any]]" has no attribute "__iter__" (not iterable) [union-attr]
+ src/pip/_internal/metadata/_json.py:70: error: Argument 1 to "sanitise_header" has incompatible type "Optional[Any]"; expected "Union[Header, str]" [arg-type]
sympy (https://github.com/sympy/sympy)
+ sympy/parsing/sympy_parser.py:1075: error: Incompatible types in assignment (expression has type "CodeType", variable has type "str") [assignment]
porcupine (https://github.com/Akuli/porcupine)
+ porcupine/utils.py:408: error: No overload variant of "asdict" matches argument type "EventDataclass" [call-overload]
+ porcupine/utils.py:408: note: Possible overload variants:
+ porcupine/utils.py:408: note: def asdict(obj: _DataclassInstance) -> Dict[str, Any]
+ porcupine/utils.py:408: note: def [_T] asdict(obj: _DataclassInstance, *, dict_factory: Callable[[List[Tuple[str, Any]]], _T]) -> _T
jinja (https://github.com/pallets/jinja)
+ src/jinja2/environment.py:706: error: Unused "type: ignore" comment
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/helpers.py:749: error: Value of type "Optional[List[Tuple[str, str]]]" is not indexable [index]
core (https://github.com/home-assistant/core)
+ homeassistant/components/p1_monitor/diagnostics.py:45: error: Argument 1 to "asdict" has incompatible type "Optional[Any]"; expected "_DataclassInstance" [arg-type]
+ homeassistant/components/zha/core/gateway.py:505: error: Argument 1 to "addFilter" of "Filterer" has incompatible type "Union[Filter, Callable[[LogRecord], int]]"; expected "Union[Filter, Callable[[LogRecord], bool]]" [arg-type]
+ homeassistant/components/zha/core/gateway.py:520: error: Argument 1 to "removeFilter" of "Filterer" has incompatible type "Union[Filter, Callable[[LogRecord], int]]"; expected "Union[Filter, Callable[[LogRecord], bool]]" [arg-type]
+ homeassistant/components/zwave_js/discovery.py:78: error: No overload variant of "asdict" matches argument type "DataclassMustHaveAtLeastOne" [call-overload]
+ homeassistant/components/zwave_js/discovery.py:78: note: Possible overload variants:
+ homeassistant/components/zwave_js/discovery.py:78: note: def asdict(obj: _DataclassInstance) -> Dict[str, Any]
+ homeassistant/components/zwave_js/discovery.py:78: note: def [_T] asdict(obj: _DataclassInstance, *, dict_factory: Callable[[List[Tuple[str, Any]]], _T]) -> _T
urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/_collections.py:269: error: Signature of "setdefault" incompatible with supertype "MutableMapping" [override]
+ src/urllib3/_collections.py:269: note: Superclass:
+ src/urllib3/_collections.py:269: note: @overload
+ src/urllib3/_collections.py:269: note: def setdefault(self, str, None = ..., /) -> Optional[str]
+ src/urllib3/_collections.py:269: note: @overload
+ src/urllib3/_collections.py:269: note: def setdefault(self, str, str, /) -> str
+ src/urllib3/_collections.py:269: note: Subclass:
+ src/urllib3/_collections.py:269: note: def setdefault(self, key: str, default: str = ...) -> str
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:1862: error: Incompatible types in assignment (expression has type "Union[Type[Any], Callable[P, R], Callable[..., Any]]", variable has type overloaded function) [assignment]
+ src/hydra_zen/structured_configs/_implementations.py:1862: error: Incompatible types in assignment (expression has type "Union[Type[_DataclassInstance], Type[Any], Callable[P, R], Callable[..., Any], DataClass_]", variable has type overloaded function) [assignment]
|
Collaborator
|
pip and aiohttp: python/typeshed#9620 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source commit: python/typeshed@37a180e
NOTE: "rebase and merge" is much more preferable than "squash and merge" for this PR. These two commits no longer apply cleanly, which caused the automated workflow to fail a few days ago (hence this manual PR):
mypy/misc/sync-typeshed.py
Lines 188 to 189 in 11739e4
If we use "rebase and merge" for this PR, we will be able to update those lines in the script with the second and third commits from this PR, meaning we can go back to automated typeshed syncs in the future.