Skip to content
Snippets Groups Projects
Commit 5e1a64f3 authored by Bryce Guinta's avatar Bryce Guinta
Browse files

Stop generated builtin str methods from referencing a dummy class

This class, called 'whatever' ended up appearing in pyreverse
due to a local called __class__ which pointed to it. pyreverse
seemed to have found this class by recursively visiting nodes
and calling the values() method of each node.

Closes PyCQA/pylint#1875
parent 8a46e01c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -74,6 +74,11 @@ def _extend_str(class_node, rvalue):
code = code.format(rvalue=rvalue)
fake = AstroidBuilder(MANAGER).string_build(code)['whatever']
for method in fake.mymethods():
method.parent = class_node
method.lineno = None
method.col_offset = None
if '__class__' in method.locals:
method.locals['__class__'] = [class_node]
class_node.locals[method.name] = [method]
method.parent = class_node
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment