Uh oh!
There was an error while loading. Please reload this page.
Remove redundant inheritances from Iterator in builtins - #12851
Conversation
This comment has been minimized.
This comment has been minimized.
tungol
commented
Oct 18, 2024
Three of the hits look like the ternary join issue again: Here's Spack: defanchorify(data: dict|list) ->None:
forkey, valueindata.items() ifisinstance(data, dict) elseenumerate(data):
passOptuna: deffoo(values: list[str], names: list[str] |None):
iterator=enumerate(values) ifnamesisNoneelsezip(names, values)
foriteminiterator:
passPySpark: fromtypingimportAnydefdrop(labels: Any):
iflabelsisnotNone:
returnfoo= []
cols, labels=zip(*foo) iflen(foo) >0else ([], [])
[labelforlabelinlabels]Ibis and psycopg show errors going away, and I think represent mypy inferring Any where it didn't before. The error from Ibis going away looks like this: fromcollections.abcimportIterableclassValue:
defcases(self, *branches: tuple[Value, Value]) ->Value: ...
deflabel(self, labels: Iterable[str]) ->Value:
returnself.cases(*enumerate(labels))Take away the < tests/types/test_datetime.py:785: error: Argument 1 to "time" has incompatible type "*map[int]"; expected "tzinfo | None" [arg-type]< tests/types/test_datetime.py:807: error: Argument 1 to "datetime" has incompatible type "*map[int]"; expected "tzinfo | None" [arg-type]Which comes from something like this: importdatetimedefas_time(s):
datetime.time(*map(int, s.split(",")))
defas_naive_dt(s):
datetime.datetime(*map(int, s.split(",")))Following on from the revert and discussion of the related itertools MR (#12816 and #12853 ), I believe that all of these are blocking. I'll close out this MR in a day or two if nobody else has anything to say about it. |
tungol
commented
Oct 19, 2024
Moving this to open since the revert of #12816 wasn't necessary. I'm pretty sure the three new messages in mypy-primer will go away for mypy 1.12. |
hauntsaninja
commented
Oct 19, 2024
Let's update typeshed to latest mypy to confirm before merging this! |
hauntsaninja
commented
Oct 19, 2024
Also this class of change probably makes type checkers slower, since structural checks are more expensive than nominal checks |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: psycopg (https://github.com/psycopg/psycopg)
+ tests/types/test_datetime.py:785: error: Unused "type: ignore" comment [unused-ignore]+ tests/types/test_datetime.py:807: error: Unused "type: ignore" comment [unused-ignore]
ibis (https://github.com/ibis-project/ibis)
- ibis/expr/types/numeric.py:1223: error: Argument 1 to "cases" of "Value" has incompatible type "*enumerate[str]"; expected "tuple[Value, Value]" [arg-type] |
This is the last batch of them; I saved the builtins for last.
previous: #12813#12814#12816#12827
The unrelated extra newline in this MR was black's idea, not mine, to be clear.