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"
24
+ if PY313_PLUS and not PY313_0
25
+ else ""
26
+ + """
24
27
class defaultdict(dict):
25
28
default_factory = None
26
29
def __missing__(self, key): pass
@@ -32,7 +35,7 @@ def __getitem__(self, key): return default_factory
32
35
)
33
36
34
37
35
- def _collections_abc_313_transform () -> nodes .Module :
38
+ def _collections_abc_313_0_transform () -> nodes .Module :
36
39
"""See https://github.com/python/cpython/pull/124735"""
37
40
return AstroidBuilder (AstroidManager ()).string_build (
38
41
"from _collections_abc import *"
@@ -132,7 +135,7 @@ def register(manager: AstroidManager) -> None:
132
135
ClassDef , easy_class_getitem_inference , _looks_like_subscriptable
133
136
)
134
137
135
- if PY313_PLUS :
138
+ if PY313_0 :
136
139
register_module_extender (
137
- manager , "collections.abc" , _collections_abc_313_transform
140
+ manager , "collections.abc" , _collections_abc_313_0_transform
138
141
)
0 commit comments