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

Merged
merged 3 commits into from
Nov 18, 2022
Merged

Sync typeshed #13987

merged 3 commits into from
Nov 18, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot 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.

mypybot and 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
Contributor Author

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

@hauntsaninja hauntsaninja merged commit 6e70826 into master Nov 18, 2022
@hauntsaninja hauntsaninja 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-actions bot pushed a commit that referenced this pull request Dec 1, 2022
Since the plugin provides superior type checking:
#13987 (comment)
github-actions bot pushed a commit that referenced this pull request Dec 15, 2022
Since the plugin provides superior type checking:
#13987 (comment)
github-actions bot pushed a commit that referenced this pull request Jan 1, 2023
Since the plugin provides superior type checking:
#13987 (comment)
github-actions bot 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)
JelleZijlstra pushed a commit that referenced this pull request Mar 16, 2024
Since the plugin provides superior type checking: #13987 (comment)
A manual cherry-pick of e437cdf.
github-actions bot pushed a commit that referenced this pull request Apr 1, 2024
github-actions bot pushed a commit that referenced this pull request Apr 15, 2024
github-actions bot pushed a commit that referenced this pull request May 1, 2024
github-actions bot pushed a commit that referenced this pull request May 15, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request May 15, 2024
koogoro pushed a commit that referenced this pull request May 23, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jun 20, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jun 20, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jun 20, 2024
github-actions bot pushed a commit that referenced this pull request Jul 1, 2024
github-actions bot pushed a commit that referenced this pull request Jul 15, 2024
hauntsaninja pushed a commit that referenced this pull request Jul 23, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Jul 25, 2024
github-actions bot pushed a commit that referenced this pull request Aug 1, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Aug 30, 2024
github-actions bot pushed a commit that referenced this pull request Sep 1, 2024
github-actions bot pushed a commit that referenced this pull request Sep 15, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Sep 26, 2024
github-actions bot pushed a commit that referenced this pull request Oct 1, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Oct 16, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Oct 16, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Oct 16, 2024
cdce8p pushed a commit to cdce8p/mypy that referenced this pull request Oct 16, 2024
github-actions bot pushed a commit that referenced this pull request Oct 18, 2024
github-actions bot pushed a commit that referenced this pull request Oct 18, 2024
onlined pushed a commit to onlined/mypy that referenced this pull request Oct 27, 2024
github-actions bot pushed a commit that referenced this pull request Nov 1, 2024
github-actions bot pushed a commit that referenced this pull request Nov 6, 2024
github-actions bot pushed a commit that referenced this pull request Nov 15, 2024
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