GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — allow arbitrary types in set difference by randolf-scholz · Pull Request #15160 · python/typeshed Conversation
|
|
Diff from mypy_primer, showing the effect of this PR on open source code: pandas (https://github.com/pandas-dev/pandas) + pandas/core/dtypes/cast.py:869: error: Unused "type: ignore" comment [unused-ignore] + pandas/core/dtypes/cast.py:870: error: Unused "type: ignore" comment [unused-ignore] ibis (https://github.com/ibis-project/ibis) - ibis/backends/sql/datatypes.py:1398: error: Unsupported operand types for - ("set[type[Never]]" and "set[type[SqlglotType]]") [operator] - ibis/expr/datatypes/tests/test_core.py:581: error: Unsupported operand types for - ("set[type[Never]]" and "set[AnnotableMeta]") [operator] schemathesis (https://github.com/schemathesis/schemathesis) - src/schemathesis/config/_error.py:54: error: Argument 1 to "set" has incompatible type "Any | Unset"; expected "Iterable[Any | None]" [arg-type] + src/schemathesis/config/_error.py:54: error: Argument 1 to "set" has incompatible type "Any | Unset"; expected "Iterable[object]" [arg-type] pydantic (https://github.com/pydantic/pydantic) - pydantic/v1/main.py:924: error: Set comprehension has incompatible type Set[int | str]; expected Set[str | None] [misc] - pydantic/v1/main.py:924: note: Left operand is of type "set[str] | dict_keys[str, Any]" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm generally not a big fan of allowing object in cases like this, but the primer output (and consistency with __isub__) speaks for itself. Also, {1,2,3} - {1,2,"ab"} is a valid use case.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@srittau Maybe we should be using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I'd also like to get @AlexWaygood's opinion, as you discussed changing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This seems like a good change to me. I agree that when typeshed is too opinionated, it often causes more problems than it solves; we've been running into a few pain points on the ty issue tracker recently with similar causes. Please let's not (ever) change the parameter type to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah, that whole hashability thing is a big mess. I also recently learned one can make unhashable classes via custom metaclasses, which is concerning. Anyway, so is this good, or are there any other reasons to prefer |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think either is fine; it doesn't really make much difference for parameter annotations. We sometimes use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @randolf-scholz! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Several methods on built-in types are too strict. Annotations forset.__sub__ and related methods are inconsistent
There was an error while loading. Please reload this page.