Skip to content

Better handling of nester context #22

@BPHarris

Description

@BPHarris

This will be a large MR.

Currently rattr does not properly handle comprehensions and nested functions.

def fn(a):
    def inner(b):
        b.attr = 4
    return inner(a)

The above code snippet should give a.attr in the results but it gives b.attr. This is because functions are followed using the functions present in the function IR (i.e. the functions defined in the root context). The same problem is present for the contexts within list comprehensions for example:

[a.attr for a in thing]

should give thing.a[].attr in the results.

This could be achieved by storing the definitions and calls to functions under more specific names, such as fn:inner:<lineno> rather than inner. This should be generalised to handle anonymous lambdas (though only under certain circumstances).

NOTE

Possible duplicate of, or overlap with, #4

Metadata

Metadata

Assignees

Labels

duplicateThis issue or pull request already existsenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions