pylint-dev/astroid

PEP 695: infer generic bases

jacobtylerwalls opened this issue · 0 comments

Steps to reproduce

From test_mro_generic_3():

from astroid import extract_node

node = extract_node("""
from typing import Generic, TypeVar
T = TypeVar('T')
class A: ...
class B(A, Generic[T]): ...
class C(Generic[T]): ...
class D(B[T], C[T], Generic[T]): ...
""")

list(node._inferred_bases())

Current behavior

3.11

[<ClassDef.B l.5 at 0x10472a250>, <ClassDef.C l.6 at 0x104729650>, <ClassDef.Generic l.1788 at 0x104bfe650>]

3.12 with main branch of astroid

[<ClassDef.B l.5 at 0x104531d90>, <ClassDef.C l.6 at 0x104531ee0>, <ClassDef.Generic l.2 at 0x104f71130>]

3.12 with removing register_module_extender(manager, "typing", _typing_transform), which we would like to be able to do (see pylint-dev/pylint#9401 (comment)):

[]

I believe the inference is failing on those bases.

Expected behavior

Better solution for preserving 3.11 behavior than the _typing_transform, which stubs out the typing module very minimally (see f2120db)