-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Sync typeshed #13987
Conversation
72d79d5
to
31300ef
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
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). |
This comment has been minimized.
This comment has been minimized.
Source commit: python/typeshed@263427f
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)
67e2933
to
a5e54cd
Compare
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']]"
|
Looks like we've gained a lot of hits from python/typeshed#9194 :-/ possibly the case that |
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 |
Since the plugin provides superior type checking: python#13987 (comment)
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 :/ |
Since the plugin provides superior type checking: #13987 (comment)
Oops, looks like there was a new failure other than the ctypes ones in the new version of this PR that I missed |
Since the plugin provides superior type checking: #13987 (comment)
Since the plugin provides superior type checking: #13987 (comment)
Since the plugin provides superior type checking: #13987 (comment)
Since the plugin provides superior type checking: #13987 (comment)
Since the plugin provides superior type checking: python#13987 (comment)
Since the plugin provides superior type checking: #13987 (comment)
Since the plugin provides superior type checking: python#13987 (comment)
Since the plugin provides superior type checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: python#13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
… checking: #13987 (comment) A manual cherry-pick of e437cdf.
Sync typeshed
Source commit:
python/typeshed@263427f
Note that you will need to close and re-open the PR in order to trigger CI.