4949from astroid import context as contextmod
5050from astroid import decorators as decorators_mod
5151from astroid import mixins , util
52- from astroid .const import BUILTINS , PY39_PLUS
52+ from astroid .const import PY39_PLUS
5353from astroid .exceptions import (
5454 AstroidBuildingError ,
5555 AstroidTypeError ,
@@ -575,7 +575,7 @@ def pytype(self):
575575 :returns: The name of the type.
576576 :rtype: str
577577 """
578- return "%s .module" % BUILTINS
578+ return "builtins .module"
579579
580580 def display_type (self ):
581581 """A human readable type of this node.
@@ -1137,9 +1137,9 @@ def _infer_decorator_callchain(node):
11371137 if isinstance (result , bases .Instance ):
11381138 result = result ._proxied
11391139 if isinstance (result , ClassDef ):
1140- if result .is_subtype_of ("%s .classmethod" % BUILTINS ):
1140+ if result .is_subtype_of ("builtins .classmethod" ):
11411141 return "classmethod"
1142- if result .is_subtype_of ("%s .staticmethod" % BUILTINS ):
1142+ if result .is_subtype_of ("builtins .staticmethod" ):
11431143 return "staticmethod"
11441144 if isinstance (result , FunctionDef ):
11451145 if not result .decorators :
@@ -1152,7 +1152,7 @@ def _infer_decorator_callchain(node):
11521152 if (
11531153 isinstance (decorator , node_classes .Attribute )
11541154 and isinstance (decorator .expr , node_classes .Name )
1155- and decorator .expr .name == BUILTINS
1155+ and decorator .expr .name == "builtins"
11561156 and decorator .attrname in BUILTIN_DESCRIPTORS
11571157 ):
11581158 return decorator .attrname
@@ -1241,8 +1241,8 @@ def pytype(self):
12411241 :rtype: str
12421242 """
12431243 if "method" in self .type :
1244- return "%s .instancemethod" % BUILTINS
1245- return "%s .function" % BUILTINS
1244+ return "builtins .instancemethod"
1245+ return "builtins .function"
12461246
12471247 def display_type (self ):
12481248 """A human readable type of this node.
@@ -1541,7 +1541,7 @@ def type(
15411541 if (
15421542 isinstance (node , node_classes .Attribute )
15431543 and isinstance (node .expr , node_classes .Name )
1544- and node .expr .name == BUILTINS
1544+ and node .expr .name == "builtins"
15451545 and node .attrname in BUILTIN_DESCRIPTORS
15461546 ):
15471547 return node .attrname
@@ -1571,9 +1571,9 @@ def type(
15711571 for ancestor in inferred .ancestors ():
15721572 if not isinstance (ancestor , ClassDef ):
15731573 continue
1574- if ancestor .is_subtype_of ("%s .classmethod" % BUILTINS ):
1574+ if ancestor .is_subtype_of ("builtins .classmethod" ):
15751575 return "classmethod"
1576- if ancestor .is_subtype_of ("%s .staticmethod" % BUILTINS ):
1576+ if ancestor .is_subtype_of ("builtins .staticmethod" ):
15771577 return "staticmethod"
15781578 except InferenceError :
15791579 pass
@@ -2162,8 +2162,8 @@ def pytype(self):
21622162 :rtype: str
21632163 """
21642164 if self .newstyle :
2165- return "%s .type" % BUILTINS
2166- return "%s .classobj" % BUILTINS
2165+ return "builtins .type"
2166+ return "builtins .classobj"
21672167
21682168 def display_type (self ):
21692169 """A human readable type of this node.
@@ -2250,7 +2250,7 @@ def _infer_type_call(self, caller, context):
22502250
22512251 def infer_call_result (self , caller , context = None ):
22522252 """infer what a class is returning when called"""
2253- if self .is_subtype_of (f" { BUILTINS } .type" , context ) and len (caller .args ) == 3 :
2253+ if self .is_subtype_of ("builtins .type" , context ) and len (caller .args ) == 3 :
22542254 result = self ._infer_type_call (caller , context )
22552255 yield result
22562256 return
@@ -2666,7 +2666,7 @@ def has_dynamic_getattr(self, context=None):
26662666
26672667 def _valid_getattr (node ):
26682668 root = node .root ()
2669- return root .name != BUILTINS and getattr (root , "pure_python" , None )
2669+ return root .name != "builtins" and getattr (root , "pure_python" , None )
26702670
26712671 try :
26722672 return _valid_getattr (self .getattr ("__getattr__" , context )[0 ])
0 commit comments