JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
88 stars 4 forks source link

Type annotations from class-level vars from Python src ignored if no assignment #318

Closed JSAbrahams closed 1 year ago

JSAbrahams commented 2 years ago

Description of Bug

When building a context from Python source, if a class-level variable is not assigned to then type annotations are ignored.

How to Reproduce

class MyClass:
    a: int
    def __init__(self): pass

Field a does not have a type.

However, when we build a context from:

class MyClass:
    a: int = 10
    def __init__(self): pass

Field a does have type Int.

Expected behavior

Field a should be an Int in both cases.

Additional context

This appears to be an issue with the underlying python parsing library python-parser-0.1.0.:

JSAbrahams commented 1 year ago

See #319 , this is invalid Python code