Skip to content

Conversation

@koogoro
Copy link
Collaborator

@koogoro koogoro commented Feb 17, 2023

Sync latest typeshed via the sync script.

The cherry-picks with the first and second reversions were not clean, but the merges were not very complicated.

koogoro and others added 4 commits February 16, 2023 16:26
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)
@github-actions
Copy link
Contributor

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

pandas (https://github.com/pandas-dev/pandas)
+ pandas/_libs/tslibs/timestamps.pyi:138: error: Return type "datetime" of "strptime" incompatible with return type "Timestamp" in supertype "datetime"  [override]

porcupine (https://github.com/Akuli/porcupine)
- porcupine/utils.py:408: note:     def asdict(obj: _DataclassInstance) -> Dict[str, Any]
+ 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
+ porcupine/utils.py:408: note:     def [_T] asdict(obj: DataclassInstance, *, dict_factory: Callable[[List[Tuple[str, Any]]], _T]) -> _T

steam.py (https://github.com/Gobot1234/steam.py)
- steam/chat.py:401: note:     def [Self] __new__(cls: Type[Self], str, Tuple[type, ...], Dict[str, Any], /, **kwds: Any) -> Self
+ steam/chat.py:401: note:     def [_typeshed.Self] __new__(cls: Type[_typeshed.Self], str, Tuple[type, ...], Dict[str, Any], /, **kwds: Any) -> _typeshed.Self

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_libs/tslibs/timestamps.pyi:151: error: Return type "datetime" of "strptime" incompatible with return type "Timestamp" in supertype "datetime"  [override]

isort (https://github.com/pycqa/isort)
+ isort/api.py:196: error: No overload variant of "compile" matches argument types "str", "str", "str", "int", "int"  [call-overload]
+ isort/api.py:196: note: Possible overload variants:
+ isort/api.py:196: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[0], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> CodeType
+ isort/api.py:196: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, *, dont_inherit: bool = ..., optimize: int = ..., _feature_version: int = ...) -> CodeType
+ isort/api.py:196: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[1024], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> AST
+ isort/api.py:196: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: int, dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> Any
+ isort/api.py:223: error: No overload variant of "compile" matches argument types "str", "str", "str", "int", "int"  [call-overload]
+ isort/api.py:223: note: Possible overload variants:
+ isort/api.py:223: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[0], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> CodeType
+ isort/api.py:223: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, *, dont_inherit: bool = ..., optimize: int = ..., _feature_version: int = ...) -> CodeType
+ isort/api.py:223: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[1024], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> AST
+ isort/api.py:223: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: int, dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> Any

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/pydantic.py:161: note:     def [Self] __new__(cls: Type[Self], str, Tuple[type, ...], Dict[str, Any], /, **kwds: Any) -> Self
+ src/prefect/utilities/pydantic.py:161: note:     def [_typeshed.Self] __new__(cls: Type[_typeshed.Self], str, Tuple[type, ...], Dict[str, Any], /, **kwds: Any) -> _typeshed.Self
- src/prefect/utilities/pydantic.py:163: note:     def [Self] __new__(cls: Type[Self], str, Tuple[type, ...], Dict[str, Any], /, **kwds: Any) -> Self
+ src/prefect/utilities/pydantic.py:163: note:     def [_typeshed.Self] __new__(cls: Type[_typeshed.Self], str, Tuple[type, ...], Dict[str, Any], /, **kwds: Any) -> _typeshed.Self

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/runtime/scriptrunner/script_runner.py: note: In member "_run_script" of class "ScriptRunner":
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: error: No overload variant of "compile" matches argument types "Any", "str", "str", "int", "int", "int"  [call-overload]
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note: Possible overload variants:
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[0], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> CodeType
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, *, dont_inherit: bool = ..., optimize: int = ..., _feature_version: int = ...) -> CodeType
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[1024], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> AST
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note:     def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: int, dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> Any

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[_DataclassInstance], Type[Any], Callable[P, R], Callable[..., Any], DataClass_]", 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]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/son.py: note: In member "__new__" of class "SON":
+ bson/son.py:69: error: Value of type variable "Self" of "__new__" of "dict" cannot be "SON[_Key, _Value]"  [type-var]

@hauntsaninja
Copy link
Collaborator

pandas, pandas-stubs: python/typeshed#9706
isort, streamlit: python/typeshed#9672
bson: python/typeshed#9694

@hauntsaninja hauntsaninja merged commit f968d6c into python:master Feb 17, 2023
@hauntsaninja
Copy link
Collaborator

Thank you!

hauntsaninja added a commit that referenced this pull request Feb 17, 2023
@koogoro koogoro deleted the mypybot/sync-typeshed branch February 18, 2023 00:23
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.

2 participants