8
8
9
9
from astroid .brain .helpers import register_module_extender
10
10
from astroid .builder import AstroidBuilder , extract_node , parse
11
- from astroid .const import PY313_PLUS
11
+ from astroid .const import PY313_0 , PY313_PLUS
12
12
from astroid .context import InferenceContext
13
13
from astroid .exceptions import AttributeInferenceError
14
14
from astroid .manager import AstroidManager
20
20
21
21
def _collections_transform ():
22
22
return parse (
23
- """
23
+ (" import _collections_abc as abc" if PY313_PLUS and not PY313_0 else "" )
24
+ + """
24
25
class defaultdict(dict):
25
26
default_factory = None
26
27
def __missing__(self, key): pass
@@ -32,7 +33,7 @@ def __getitem__(self, key): return default_factory
32
33
)
33
34
34
35
35
- def _collections_abc_313_transform () -> nodes .Module :
36
+ def _collections_abc_313_0_transform () -> nodes .Module :
36
37
"""See https://github.com/python/cpython/pull/124735"""
37
38
return AstroidBuilder (AstroidManager ()).string_build (
38
39
"from _collections_abc import *"
@@ -132,7 +133,7 @@ def register(manager: AstroidManager) -> None:
132
133
ClassDef , easy_class_getitem_inference , _looks_like_subscriptable
133
134
)
134
135
135
- if PY313_PLUS :
136
+ if PY313_0 :
136
137
register_module_extender (
137
- manager , "collections.abc" , _collections_abc_313_transform
138
+ manager , "collections.abc" , _collections_abc_313_0_transform
138
139
)
0 commit comments