6
6
7
7
from astroid .brain .helpers import register_module_extender
8
8
from astroid .builder import extract_node , parse
9
- from astroid .const import PY39_PLUS
10
9
from astroid .context import InferenceContext
11
10
from astroid .exceptions import AttributeInferenceError
12
11
from astroid .manager import AstroidManager
@@ -61,9 +60,7 @@ def __add__(self, other): pass
61
60
def __iadd__(self, other): pass
62
61
def __mul__(self, other): pass
63
62
def __imul__(self, other): pass
64
- def __rmul__(self, other): pass"""
65
- if PY39_PLUS :
66
- base_deque_class += """
63
+ def __rmul__(self, other): pass
67
64
@classmethod
68
65
def __class_getitem__(self, item): return cls"""
69
66
return base_deque_class
@@ -73,9 +70,7 @@ def _ordered_dict_mock():
73
70
base_ordered_dict_class = """
74
71
class OrderedDict(dict):
75
72
def __reversed__(self): return self[::-1]
76
- def move_to_end(self, key, last=False): pass"""
77
- if PY39_PLUS :
78
- base_ordered_dict_class += """
73
+ def move_to_end(self, key, last=False): pass
79
74
@classmethod
80
75
def __class_getitem__(cls, item): return cls"""
81
76
return base_ordered_dict_class
@@ -116,11 +111,10 @@ def easy_class_getitem_inference(node, context: InferenceContext | None = None):
116
111
def register (manager : AstroidManager ) -> None :
117
112
register_module_extender (manager , "collections" , _collections_transform )
118
113
119
- if PY39_PLUS :
120
- # Starting with Python39 some objects of the collection module are subscriptable
121
- # thanks to the __class_getitem__ method but the way it is implemented in
122
- # _collection_abc makes it difficult to infer. (We would have to handle AssignName inference in the
123
- # getitem method of the ClassDef class) Instead we put here a mock of the __class_getitem__ method
124
- manager .register_transform (
125
- ClassDef , easy_class_getitem_inference , _looks_like_subscriptable
126
- )
114
+ # Starting with Python39 some objects of the collection module are subscriptable
115
+ # thanks to the __class_getitem__ method but the way it is implemented in
116
+ # _collection_abc makes it difficult to infer. (We would have to handle AssignName inference in the
117
+ # getitem method of the ClassDef class) Instead we put here a mock of the __class_getitem__ method
118
+ manager .register_transform (
119
+ ClassDef , easy_class_getitem_inference , _looks_like_subscriptable
120
+ )
0 commit comments