Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actionsgithub-actionsbot commented Nov 2, 2022

Sync typeshed

Source commit:
python/typeshed@263427f

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

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator

We should revert the typeshed ctypes change in mypy's vendored copy, since the plugin seems to provide strictly better type checking (I briefly looked into fixing the plugin, but it wasn't immediately obvious to me how).

@github-actions

This comment has been minimized.

mypybotand others added 3 commits November 15, 2022 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)
@github-actions
Copy link
ContributorAuthor

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

sphinx (https://github.com/sphinx-doc/sphinx) + sphinx/builders/gettext.py:191:7: error: Cannot instantiate abstract class "LocalTimeZone" with abstract attribute "tzname" [abstract] pandas-stubs (https://github.com/pandas-dev/pandas-stubs) + tests/test_scalars.py:487: error: Unused "type: ignore" comment psycopg (https://github.com/psycopg/psycopg) + psycopg/psycopg/types/numeric.py:394: error: Unused "type: ignore" comment+ psycopg/psycopg/types/numeric.py:396: error: Unused "type: ignore" comment pydantic (https://github.com/samuelcolvin/pydantic) + pydantic/_internal/_validators.py:160: error: Unsupported operand types for >= ("Literal['n']" and "int") [operator]+ pydantic/_internal/_validators.py:160: error: Unsupported operand types for >= ("Literal['N']" and "int") [operator]+ pydantic/_internal/_validators.py:160: error: Unsupported operand types for >= ("Literal['F']" and "int") [operator]+ pydantic/_internal/_validators.py:160: note: Left operand is of type "Union[int, Literal['n', 'N', 'F']]"+ pydantic/_internal/_validators.py:162: error: Unsupported operand types for + ("int" and "Literal['n']") [operator]+ pydantic/_internal/_validators.py:162: error: Unsupported operand types for + ("int" and "Literal['N']") [operator]+ pydantic/_internal/_validators.py:162: error: Unsupported operand types for + ("int" and "Literal['F']") [operator]+ pydantic/_internal/_validators.py:162: note: Right operand is of type "Union[int, Literal['n', 'N', 'F']]"+ pydantic/_internal/_validators.py:170: error: Argument 1 to "abs" has incompatible type "Union[int, Literal['n', 'N', 'F']]"; expected "SupportsAbs[int]" [arg-type]+ pydantic/_internal/_validators.py:171: error: Argument 1 to "abs" has incompatible type "Union[int, Literal['n', 'N', 'F']]"; expected "SupportsAbs[int]" [arg-type]+ pydantic/_internal/_validators.py:174: error: Argument 1 to "abs" has incompatible type "Union[int, Literal['n', 'N', 'F']]"; expected "SupportsAbs[int]" [arg-type]+ pydantic/json.py:38: error: Unsupported operand types for >= ("Literal['n']" and "int") [operator]+ pydantic/json.py:38: error: Unsupported operand types for >= ("Literal['N']" and "int") [operator]+ pydantic/json.py:38: error: Unsupported operand types for >= ("Literal['F']" and "int") [operator]+ pydantic/json.py:38: note: Left operand is of type "Union[int, Literal['n', 'N', 'F']]" spark (https://github.com/apache/spark) + python/pyspark/sql/connect/column.py:180: error: Argument 1 to "abs" has incompatible type "Union[int, Literal['n', 'N', 'F']]"; expected "SupportsAbs[int]" [arg-type]+ python/pyspark/sql/connect/column.py:181: error: Argument 1 to "abs" has incompatible type "Union[int, Literal['n', 'N', 'F']]"; expected "SupportsAbs[int]" [arg-type] bandersnatch (https://github.com/pypa/bandersnatch) + src/bandersnatch_storage_plugins/swift.py: note: In member "write_bytes" of class "SwiftPath":+ src/bandersnatch_storage_plugins/swift.py:408: error: Signature of "write_bytes" incompatible with supertype "Path" [override]+ src/bandersnatch_storage_plugins/swift.py:408: note: Superclass:+ src/bandersnatch_storage_plugins/swift.py:408: note: def write_bytes(self, data: Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]]) -> int+ src/bandersnatch_storage_plugins/swift.py:408: note: Subclass:+ src/bandersnatch_storage_plugins/swift.py:408: note: def write_bytes(self, contents: bytes, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int discord.py (https://github.com/HitSyr/discord.py) - discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]" [arg-type]+ discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "_ClassInfo" [arg-type]- discord/ext/commands/hybrid.py:206: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]" [arg-type]+ discord/ext/commands/hybrid.py:206: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "_ClassInfo" [arg-type] core (https://github.com/home-assistant/core) + homeassistant/components/dsmr/sensor.py:572: error: Incompatible types in assignment (expression has type "int", variable has type "Optional[str]") [assignment]+ homeassistant/components/dsmr/sensor.py:579: error: Statement is unreachable [unreachable]+ homeassistant/components/nissan_leaf/sensor.py:129: error: Returning Any from function declared to return "Optional[float]" [no-any-return]+ homeassistant/components/elgato/light.py:95: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/tradfri/sensor.py:67: error: Returning Any from function declared to return "int" [no-any-return]+ homeassistant/components/tplink/light.py:272: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/fritzbox/light.py:157: error: Returning Any from function declared to return "Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]" [no-any-return]+ homeassistant/components/shelly/light.py:198: error: Returning Any from function declared to return "int" [no-any-return]+ homeassistant/components/accuweather/sensor.py:256: error: Returning Any from function declared to return "Union[None, str, int, float]" [no-any-return]+ homeassistant/components/esphome/light.py:267: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/esphome/cover.py:93: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/esphome/cover.py:101: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/zwave_js/light.py:180: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/zwave_js/cover.py:132: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/isy994/light.py:73: error: Returning Any from function declared to return "Optional[int]" [no-any-return]+ homeassistant/components/isy994/cover.py:61: error: Returning Any from function declared to return "Optional[int]" [no-any-return] mongo-python-driver (https://github.com/mongodb/mongo-python-driver) + bson/decimal128.py: note: In function "_decimal_to_128":+ bson/decimal128.py:103: error: Unsupported operand types for + ("Literal['n']" and "int") [operator]+ bson/decimal128.py:103: error: Unsupported operand types for + ("Literal['N']" and "int") [operator]+ bson/decimal128.py:103: error: Unsupported operand types for + ("Literal['F']" and "int") [operator]+ bson/decimal128.py:103: note: Left operand is of type "Union[int, Literal['n', 'N', 'F']]"

@hauntsaninja
Copy link
Collaborator

Looks like we've gained a lot of hits from python/typeshed#9194 :-/ possibly the case that int | Any is better, but hard to say

@hauntsaninja
Copy link
Collaborator

Anyway, I'm going to merge this, so that I can revert ctypes in its own commit, so that it's easy to cherry pick

@hauntsaninjahauntsaninja merged commit 6e70826 into masterNov 18, 2022
@hauntsaninjahauntsaninja deleted the mypybot/sync-typeshed branch November 18, 2022 09:01
hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull request Nov 18, 2022
Since the plugin provides superior type checking: python#13987 (comment)
@AlexWaygood
Copy link
Member

Looks like we've gained a lot of hits from python/typeshed#9194 :-/ possibly the case that int | Any is better, but hard to say

It's worth noting that most of those hits are multiline errors, so it's not quite as bad as it looks at first glance... But, yeah, agreed that it's on the disruptive side :/

hauntsaninja added a commit that referenced this pull request Nov 18, 2022
Since the plugin provides superior type checking: #13987 (comment)
@hauntsaninja
Copy link
Collaborator

Oops, looks like there was a new failure other than the ctypes ones in the new version of this PR that I missed

github-actionsbot pushed a commit that referenced this pull request Dec 1, 2022
Since the plugin provides superior type checking: #13987 (comment)
github-actionsbot pushed a commit that referenced this pull request Dec 15, 2022
Since the plugin provides superior type checking: #13987 (comment)
github-actionsbot pushed a commit that referenced this pull request Jan 1, 2023
Since the plugin provides superior type checking: #13987 (comment)
github-actionsbot pushed a commit that referenced this pull request Jan 15, 2023
Since the plugin provides superior type checking: #13987 (comment)
AlexWaygood pushed a commit to AlexWaygood/mypy that referenced this pull request Feb 3, 2023
Since the plugin provides superior type checking: python#13987 (comment)
hauntsaninja added a commit that referenced this pull request Feb 3, 2023
Since the plugin provides superior type checking: #13987 (comment)
koogoro pushed a commit to koogoro/mypy that referenced this pull request Feb 15, 2023
Since the plugin provides superior type checking: python#13987 (comment)
github-actionsbot pushed a commit that referenced this pull request Mar 1, 2025
github-actionsbot pushed a commit that referenced this pull request Mar 15, 2025
hauntsaninja pushed a commit that referenced this pull request Mar 16, 2025
github-actionsbot pushed a commit that referenced this pull request Apr 1, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Apr 2, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Apr 4, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Apr 16, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request May 10, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request May 19, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request May 27, 2025
github-actionsbot pushed a commit that referenced this pull request Jun 1, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jun 1, 2025
github-actionsbot pushed a commit that referenced this pull request Jun 15, 2025
github-actionsbot pushed a commit that referenced this pull request Jul 1, 2025
github-actionsbot pushed a commit that referenced this pull request Jul 15, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Aug 4, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Aug 15, 2025
KevinRK29 pushed a commit to KevinRK29/mypy that referenced this pull request Aug 18, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Aug 31, 2025
github-actionsbot pushed a commit that referenced this pull request Sep 15, 2025
github-actionsbot pushed a commit that referenced this pull request Oct 1, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Oct 16, 2025
github-actionsbot pushed a commit that referenced this pull request Nov 1, 2025
github-actionsbot pushed a commit that referenced this pull request Nov 15, 2025
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Nov 15, 2025
github-actionsbot pushed a commit that referenced this pull request Dec 1, 2025
github-actionsbot pushed a commit that referenced this pull request Dec 15, 2025
github-actionsbot pushed a commit that referenced this pull request Jan 1, 2026
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jan 17, 2026
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jan 17, 2026
The plugin provides superior type checking: python#13987 (comment) A manual cherry-pick of e437cdf.
Sign up for freeto 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.

4 participants

@hauntsaninja@AlexWaygood@JelleZijlstra