expand the possible inputs to reversed#13269
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
+ python/pyspark/pandas/base.py:1663: error: Unused "type: ignore" comment [unused-ignore]
pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/monkeypatch.py:402: error: Unused "type: ignore" comment [unused-ignore]
+ src/_pytest/monkeypatch.py:407: error: Unused "type: ignore" comment [unused-ignore]
|
|
I don't think this really does what we'd want because mypy doesn't handle It's a tough spot to be in. We can expand what reversed will accept in it's constructor, but without mypy support it's only going to result in I'll check out the mypy-primer hits though to see what's going on and if they're actually being cleared in a reasonable way. Related: python/mypy#15182 |
|
That said this does work as expected in pyright. |
|
|
||
| class reversed(Generic[_T]): | ||
| @overload | ||
| def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc] |
There was a problem hiding this comment.
I don't think we even need this overload. The second overload should include this one.
|
We could also use some test cases for this. |
|
I don't think we can do this without mypy support, whether that's python/mypy#15182 or special-casing for For example, it's true that we don't need the first overload, but without that, and with the current state of mypy, we would get We could, with more safety, expand this to accept So I don't really think it's worth worrying about test cases; this is busted and we shouldn't do it right now. |
A bit experimental.
related to #13218 and #11645