88
99from astroid .brain .helpers import register_module_extender
1010from astroid .builder import AstroidBuilder , extract_node , parse
11- from astroid .const import PY313_PLUS
11+ from astroid .const import PY313_0 , PY313_PLUS
1212from astroid .context import InferenceContext
1313from astroid .exceptions import AttributeInferenceError
1414from astroid .manager import AstroidManager
2020
2121def _collections_transform ():
2222 return parse (
23- """
23+ (" import _collections_abc as abc" if PY313_PLUS and not PY313_0 else "" )
24+ + """
2425 class defaultdict(dict):
2526 default_factory = None
2627 def __missing__(self, key): pass
@@ -32,7 +33,7 @@ def __getitem__(self, key): return default_factory
3233 )
3334
3435
35- def _collections_abc_313_transform () -> nodes .Module :
36+ def _collections_abc_313_0_transform () -> nodes .Module :
3637 """See https://github.com/python/cpython/pull/124735"""
3738 return AstroidBuilder (AstroidManager ()).string_build (
3839 "from _collections_abc import *"
@@ -132,7 +133,7 @@ def register(manager: AstroidManager) -> None:
132133 ClassDef , easy_class_getitem_inference , _looks_like_subscriptable
133134 )
134135
135- if PY313_PLUS :
136+ if PY313_0 :
136137 register_module_extender (
137- manager , "collections.abc" , _collections_abc_313_transform
138+ manager , "collections.abc" , _collections_abc_313_0_transform
138139 )
0 commit comments