Uh oh!
There was an error while loading. Please reload this page.
Do not count __slots__ as a protocol member - #11885
Conversation
AlexWaygood
commented
Jan 2, 2022
It's not so clear-cut, but would it be worth special-casing |
sobolevn
commented
Jan 2, 2022
Can you please open a new issue for it? Probably we need to discuss / research all special cases separatelly. But, it looks like a good candidate 👍 |
AlexWaygood
commented
Jan 2, 2022
Sure! |
AlexWaygood
commented
Jan 2, 2022
New issue filed here: #11886 |
sobolevn
commented
Jan 2, 2022
Now I am also thinking: what if I want to have a function / interface / contract / whatever that only works with slotted types? How can I express this? For example: defpretty_print_slots(klass_with_slots: ???) ->None:
...I guess what Eric said in #11886 really makes sense. So, proably we can ignore protocols Do you agree? |
That sounds like a decent solution too, tried it out a bit and found some weird behavior in current mypy somewhat related to this, just bringing this up because it's a bit funny: This fails: importtyping@typing.runtime_checkableclassFoo(typing.Protocol):
__slots__= ()
classBar(Foo):
...
print(issubclass(Bar, Foo)) # this failsand this works: importtyping@typing.runtime_checkableclassFoo(typing.Protocol):
__slots__: str|typing.Iterable[str] = ()
classBar(Foo):
...
print(issubclass(Bar, Foo)) # this does not ?(Anyways, that'll get fixed by this too, it's just some weird behavior...) Basically yes, I agree that would make sense to me -- though I'm sure any solution would be nice. |
sobolevn
commented
Jan 3, 2022
We are blocked by #11891 |
I wonder if it's even helpful for typeshed to define |
sobolevn
commented
Jan 3, 2022
@AlexWaygood well, technically, My vote is to remove them (my opinion is pretty simple: typeshed should be as close to source as possible). |
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/core.py:2333: error: Argument 1 to "is_owner" of "BotBase" has incompatible type "Union[discord.user.User, Member]"; expected "discord.abc.User" |
HexDecimal
commented
Jun 21, 2023
What's the status of this? Instead of hard-coding Maybe I should try making a separate PR with my suggestions? |
sobolevn
commented
Jun 21, 2023
@HexDecimal I've deleted my fork by accident. You can re-submit this if you need this feature :) |
HexDecimal
commented
Jun 21, 2023
I'll go ahead and attempt my own PR. I mostly want to fetch your test to work with. |
sobolevn
commented
Jun 21, 2023
Great, ping me to review your PR :) |
Refs #9314
Closes#11884