Scope metadata doesn't include instance variables
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 229
- PR merge metrics
- No merged PRs in 30d
Description
It seems as though instance variables are not included in the class scope, whereas class variables are.
Example:
```python
import libcst as cst
source = """
class A:
foo = 0
def __init__(self):
self.bar = 1
"""
wrapper = cst.metadata.MetadataWrapper(cst.parse_module(source))
scopes = set(wrapper.resolve(cst.metadata.ScopeProvider).values())
for scope in scopes:
print(getattr(scope, 'name', 'global'), ':', [i.name for i in scope.assignments])
```
Output:
```
global : ['A']
A : ['foo', '__init__']
__init__ : ['self']
```
Expected output:
```
global : ['A']
A : ['foo', '__init__', 'bar']
__init__ : ['self']
```
Is this the intended behavior? It seems like it would be useful to have instance variables included in the scope metadata, but I guess this might be hard work because the assignment is to `self.bar` instead of just to `bar`.
Contributor guide
Assessment
This issue has not been assessed yet.