Skip to content
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

Sync typeshed #15792

Merged
merged 6 commits into from
Aug 12, 2023
Merged

Sync typeshed #15792

merged 6 commits into from
Aug 12, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 1, 2023

Sync typeshed

Source commit:
python/typeshed@fe2ebd6

Note that you will need to close and re-open the PR in order to trigger CI.

mypybot and others added 5 commits August 1, 2023 00:05
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: #13987 (comment)
A manual cherry-pick of e437cdf.
@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

AlexWaygood commented Aug 1, 2023

Primer hits:

The test failure is caused by python/typeshed#10464. Should be fairly easy to resolve, I think (but I can't push to this branch).

@github-actions
Copy link
Contributor Author

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

anyio (https://github.com/agronholm/anyio)
+ src/anyio/streams/memory.py:226: error: Unused "type: ignore" comment  [unused-ignore]
+ src/anyio/streams/memory.py:231: error: Unused "type: ignore" comment  [unused-ignore]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/id.py:276: error: Need type annotation for "__class_getitem__"  [var-annotated]
+ steam/ext/commands/utils.py:38: note:          def get(self, str, _VT, /) -> _VT
+ steam/ext/commands/utils.py:38: note:          @overload
- steam/ext/commands/utils.py:38: note:          def [_T] get(self, str, _VT | _T, /) -> _VT | _T
+ steam/ext/commands/utils.py:38: note:          def [_T] get(self, str, _T, /) -> _VT | _T
+ steam/ext/commands/utils.py:49: note:          def pop(self, str, _VT, /) -> _VT
+ steam/ext/commands/utils.py:49: note:          @overload
- steam/ext/commands/utils.py:49: note:          def [_T] pop(self, str, _VT | _T, /) -> _VT | _T
+ steam/ext/commands/utils.py:49: note:          def [_T] pop(self, str, _T, /) -> _VT | _T
+ steam/ext/commands/utils.py:49: note:          def pop(self, str, /, default: _VT) -> _VT
+ steam/ext/commands/utils.py:49: note:          @overload
- steam/ext/commands/utils.py:49: note:          def [_T] pop(self, str, /, default: _VT | _T) -> _VT | _T
+ steam/ext/commands/utils.py:49: note:          def [_T] pop(self, str, /, default: _T) -> _VT | _T
- steam/state.py:446: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "Friend | CMsgClientFriendsListFriend"  [arg-type]
+ steam/state.py:446: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "CMsgClientFriendsListFriend"  [arg-type]

pylox (https://github.com/sco1/pylox)
+ pylox/containers/array.py:84: note:     def pop(self, Any, Any, /) -> Any
- pylox/containers/array.py:84: note:     def [_T] pop(self, Any, Any | _T, /) -> Any | _T
+ pylox/containers/array.py:84: note:     def [_T] pop(self, Any, _T, /) -> Any | _T

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/results.py:400: note:          abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:400: note:          abstractclassmethod[BaseResult[R], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
- src/prefect/results.py:437: note:          abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:437: note:          abstractclassmethod[BaseResult[R], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
- src/prefect/results.py:509: note:          abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:509: note:          abstractclassmethod[BaseResult[R], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]

pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/api_jwk.py:73: error: Returning Any from function declared to return "str | None"  [no-any-return]
+ jwt/api_jwk.py:77: error: Returning Any from function declared to return "str | None"  [no-any-return]
+ jwt/api_jwk.py:81: error: Returning Any from function declared to return "str | None"  [no-any-return]

operator (https://github.com/canonical/operator)
- ops/testing.py:929: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "dict[str, str] | Mapping[str, str]"  [arg-type]
+ ops/testing.py:929: error: Argument 2 to "get" of "dict" has incompatible type "None"; expected "Mapping[str, str]"  [arg-type]
- ops/testing.py:2014: note:     def [_T] pop(self, int, dict[str, Any] | _T, /) -> dict[str, Any] | _T
+ ops/testing.py:2014: note:     def pop(self, int, dict[str, Any], /) -> dict[str, Any]
+ ops/testing.py:2014: note:     def [_T] pop(self, int, _T, /) -> dict[str, Any] | _T

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/config/argparsing.py:445: error: Incompatible return value type (got "Namespace | None", expected "Namespace")  [return-value]

jax (https://github.com/google/jax)
+ jax/_src/core.py:2988: error: Cannot call function of unknown type  [operator]

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/job.py: note: In function "_setup":
+ cwltool/job.py:193:21: error: Returning Any from function declared to return "bool"  [no-any-return]

speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
- backend/services/user_updater_helpers.py:190: error: Incompatible types in assignment (expression has type "list[list[Run]] | list[Run]", variable has type "list[Run]")  [assignment]
+ backend/services/user_updater_helpers.py:190: error: Incompatible types in assignment (expression has type "list[list[Run]]", variable has type "list[Run]")  [assignment]
- backend/services/user_updater_helpers.py:190: error: Argument 2 to "get" of "dict" has incompatible type "list[<nothing>]"; expected "list[list[Run]] | list[Run]"  [arg-type]
- backend/services/user_updater_helpers.py:190: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
- backend/services/user_updater_helpers.py:190: note: Consider using "Sequence" instead, which is covariant
- backend/services/user_updater_helpers.py:196: error: Incompatible types in assignment (expression has type "list[list[Run]] | list[Run]", variable has type "list[Run]")  [assignment]
+ backend/services/user_updater_helpers.py:196: error: Incompatible types in assignment (expression has type "list[list[Run]]", variable has type "list[Run]")  [assignment]
- backend/services/user_updater_helpers.py:196: error: Argument 2 to "get" of "dict" has incompatible type "list[<nothing>]"; expected "list[list[Run]] | list[Run]"  [arg-type]
- backend/services/user_updater_helpers.py:196: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
- backend/services/user_updater_helpers.py:196: note: Consider using "Sequence" instead, which is covariant

ibis (https://github.com/ibis-project/ibis)
- ibis/common/grounds.py:113: note:          classmethod[type, [VarArg(Any), KwArg(Any)], Any]
+ ibis/common/grounds.py:113: note:          classmethod[Any, [VarArg(Any), KwArg(Any)], Any]
- ibis/common/grounds.py:116: error: Argument 1 to "__get__" of "classmethod" has incompatible type "None"; expected "type"  [arg-type]
- ibis/common/grounds.py:116: error: Argument 2 to "__get__" of "classmethod" has incompatible type "type[Self]"; expected "type[type] | None"  [arg-type]
- ibis/common/grounds.py:122: error: Argument 1 to "__get__" of "classmethod" has incompatible type "None"; expected "type"  [arg-type]
- ibis/common/grounds.py:122: error: Argument 2 to "__get__" of "classmethod" has incompatible type "type[Self]"; expected "type[type] | None"  [arg-type]
- ibis/expr/analysis.py:209: error: Unsupported operand types for + ("list[Expr | None]" and "list[Expr]")  [operator]

streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/elements/date_input_test.py: note: In member "test_range_session_state" of class "DateInputTest":
- lib/tests/streamlit/elements/date_input_test.py:174:16: error: Non-overlapping equality check (left operand type: "Union[date, Tuple[()], Tuple[date], Tuple[date, date]]", right operand type: "List[datetime]")  [comparison-overlap]

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/mzcompose/__init__.py:979: note:          def parse_known_args(self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ...) -> tuple[Namespace, list[str]]
+ misc/python/materialize/mzcompose/__init__.py:979: note:          def parse_known_args(self, args: Optional[Sequence[str]] = ..., namespace: None = ...) -> tuple[Namespace, list[str]]
- misc/python/materialize/cli/mzcompose.py:673: note:          def parse_known_args(self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ...) -> tuple[Namespace, list[str]]
+ misc/python/materialize/cli/mzcompose.py:673: note:          def parse_known_args(self, args: Optional[Sequence[str]] = ..., namespace: None = ...) -> tuple[Namespace, list[str]]
+ misc/python/materialize/cli/mzcompose.py:680: error: Incompatible return value type (got "tuple[Optional[Namespace], list[str]]", expected "tuple[Namespace, list[str]]")  [return-value]
- misc/python/materialize/cli/mzcompose.py:684: note:          def parse_known_args(self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ...) -> tuple[Namespace, list[str]]
+ misc/python/materialize/cli/mzcompose.py:684: note:          def parse_known_args(self, args: Optional[Sequence[str]] = ..., namespace: None = ...) -> tuple[Namespace, list[str]]
+ misc/python/materialize/cli/mzcompose.py:691: error: Incompatible return value type (got "tuple[Optional[Namespace], list[str]]", expected "tuple[Namespace, list[str]]")  [return-value]

@hauntsaninja hauntsaninja merged commit 89c6596 into master Aug 12, 2023
17 checks passed
@hauntsaninja hauntsaninja deleted the mypybot/sync-typeshed branch August 12, 2023 07:10
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