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 #14902

Merged
merged 6 commits into from
Mar 15, 2023
Merged

Sync typeshed #14902

merged 6 commits into from
Mar 15, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Mar 15, 2023

Source commit: python/typeshed@a544b75.

The automated PR failed again last night due to merge conflicts caused by python/typeshed@28dd6c1: https://github.com/python/mypy/actions/runs/4421332699/jobs/7752003840#step:5:55

⚠️ Remember to use "rebase and merge" rather than "squash and merge" for this PR, so that we can easily update the commit hashes to cherry-pick in the misc/sync-typeshed.py script.

AlexWaygood and others added 5 commits March 15, 2023 11:48
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

This comment has been minimized.

@AlexWaygood AlexWaygood marked this pull request as draft March 15, 2023 12:17
@AlexWaygood AlexWaygood marked this pull request as ready for review March 15, 2023 13:51
@AlexWaygood
Copy link
Member Author

Mypy_primer analysis

Comment on lines -271 to +273
_program.py:5: error: Argument 1 to "write" of "IO" has incompatible type "bytes"; expected "str"
_program.py:5: error: No overload variant of "write" of "IO" matches argument type "bytes"
_program.py:5: note: Possible overload variants:
_program.py:5: note: def write(self, str, /) -> int
Copy link
Member Author

@AlexWaygood AlexWaygood Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in error message here is slightly unfortunate; the previous error message was better. It's due to a combination of python/typeshed#9861, which made IO.write an overloaded method, and #14882, which means that mypy now correctly deduces that only one overload applies in this specific situation.

@github-actions
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
+ sympy/polys/solvers.py:34: error: Cannot infer type of lambda  [misc]
+ sympy/polys/solvers.py:34: error: Argument 1 to "staticmethod" has incompatible type "Callable[[Any], Any]"; expected "Callable[[Any, Any, Any, Any, Any, Any], Any]"  [arg-type]

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/copy.py:464: error: Unused "type: ignore" comment

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/conversion.py:123: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:123: error: Untyped decorator makes function "async_caches" untyped  [misc]
- tanjun/conversion.py:129: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:129: error: Untyped decorator makes function "cache_components" untyped  [misc]
- tanjun/conversion.py:152: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:152: error: Untyped decorator makes function "intents" untyped  [misc]
- tanjun/conversion.py:390: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:454: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:508: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:557: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:602: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:675: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:732: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:784: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:839: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/conversion.py:951: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/parsing.py:463: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/clients.py:1342: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/clients.py:1342: error: Untyped decorator makes function "set_global_commands" untyped  [misc]
- tanjun/annotations.py:524: error: Module has no attribute "deprecated"  [attr-defined]
- tanjun/annotations.py:524: error: Untyped decorator makes function "default" untyped  [misc]

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/main.py:963: error: Unused "type: ignore[arg-type]" comment

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/cog.py:500: error: Incompatible types in assignment (expression has type "Callable[..., Any]", variable has type "FuncT")  [assignment]
+ discord/ext/commands/cog.py:500: error: Incompatible types in assignment (expression has type "Callable[[VarArg(Any), KwArg(Any)], Any]", variable has type "FuncT")  [assignment]

rich (https://github.com/Textualize/rich)
+ rich/progress.py:173: error: Definition of "writelines" in base class "IOBase" is incompatible with definition in base class "IO"  [misc]

pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/_internal/_decorators.py:204: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/_internal/_decorators.py:210: error: Need type annotation for "f_cls"  [var-annotated]
+ pydantic/decorators.py:91: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:102: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:113: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:123: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:145: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:161: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:170: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:179: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:189: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:204: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/decorators.py:227: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]
+ pydantic/main.py:44: error: "classmethod" expects 3 type arguments, but 1 given  [type-arg]

urllib3 (https://github.com/urllib3/urllib3)
+ test/test_ssltransport.py:443: error: Unused "type: ignore" comment
+ test/test_ssltransport.py:443: error: No overload variant of "write" of "IO" matches argument type "bytes"  [call-overload]
+ test/test_ssltransport.py:443: note: Error code "call-overload" not covered by "type: ignore" comment
+ test/test_ssltransport.py:443: note: Possible overload variants:
+ test/test_ssltransport.py:443: note:     def write(self, str, /) -> int
+ test/test_ssltransport.py:480: error: No overload variant of "write" of "IO" matches argument type "str"  [call-overload]
+ test/test_ssltransport.py:480: note: Error code "call-overload" not covered by "type: ignore" comment
+ test/test_ssltransport.py:480: note: Possible overload variants:
+ test/test_ssltransport.py:480: note:     def write(self, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], /) -> int
+ test/test_ssltransport.py:480: note:     def write(self, bytes, /) -> int

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