-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Certain multiple inheritance using generic alias errors in 3.13 #112903
Comments
Hm. Looks like this can fix it: for b in bases[i+1:]:
if (
isinstance(b, (_BaseGenericAlias, types.GenericAlias))
or issubclass(b, Generic)
):
break I will try to experiment with the fix a bit more to find if it is correct / full. |
@rmartin16 thanks for the early testing of Python 3.13! It's very helpful. And thanks @sobolevn for working on a fix. |
I'm marking this as a release blocker as it's a backwards-incompatible change that's new in Python 3.13 (@Yhg1s, please remove the label if you disagree!) |
I don't see the backwards incompatibility. It's a regression in |
The question is whether the proposed fix is the correct fix. The proposed fix uses I definitely feel like we should fix this regression before Python 3.13 is properly released, but it's probably okay to defer it for now? I don't feel qualified to comment on whether or not this should block a release, though (and if so, which release) -- that's surely up to the Release Manager :) |
I have pretty low confidence in my opinions on the proposed fix FWIW, so I'd love it if others could chime in with their opinions! |
@serhiy-storchaka, since the direct cause here was #103369 — do you have any opinions on this issue or the proposed fix? |
What's the best way to get the attention of typing-sig experts? |
I think all the people with relevant expertise on this area of code are already subscribed to this issue :) I'd say the active core devs who know this code best at this point are probably Jelle, me, Nikita and Serhiy. @carljm might also have some insight, though! |
FWIW, this issue doesn't have much to do with the intricacies of static typing (so most typing-sig experts won't have much to say on it), but it has everything to do with the mechanisms we use to achieve the runtime implementation of typing. https://docs.python.org/3/reference/datamodel.html#object.__mro_entries__, and the references listed at the bottom of the docs for that method, would be the relevant reading required to understand what's going on here, if you are interested in helping :) The difference between |
Does it work with |
It is weird. It fails for |
Ah, it is Interesting, The simpler way to reproduce the issue is: import typing
T = typing.TypeVar("T")
class A(typing.Iterable[T], list[T]): ... |
Other, even simpler, example: import typing
class A(typing.Sized, list[int]): ... |
Thanks @serhiy-storchaka for the simpler examples. They helped me find that the proposed fix is wrong; I commented on the PR. I think to fix this issue we need to either revert #103369, or add special handling to |
We have clearly established for a while now that generic aliases are not types; they have I do think the |
…115191) Co-authored-by: Alex Waygood <[email protected]>
Thanks again @rmartin16 for the early testing, thanks @encukou for bumping the issue (which I'd completely forgotten about!), and thanks @carljm for coming up with a fix! |
…_() (python#115191) Co-authored-by: Alex Waygood <[email protected]>
Bug report
Bug description:
Below is a simplification of some classes that create the problem:
Just entering these definitions in the REPL causes the error.
The stack trace (with info about variable
b
):This works "fine" before Python 3.13. If I swap the order of
typing.Dict[K, V], MutableMap[V]
, the error no longer presents on 3.13.I don't understand enough of intersection of these topics to know if this is now an expected error or something is considered wrong. This does seem related to #103369.
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs
GenericAlias
types #112926The text was updated successfully, but these errors were encountered: