Open JSAbrahams opened 2 years ago
In general we need to think about how we call unsafe python code. See #160
Actually in the above, this is not valid Python code.
Instead of adding the field to the class, the field should have no field a
.
It should only be if:
Description of Bug
If class field not assigned to in Python constructor, it should be nullable.
How to Reproduce
If we have have class:
When building a Context, we have a class
MyClass
with fielda
, which is an integer.Expected behavior
Field
a
should be typeOptional[Int]
, notInt
. This is because it is never actually assigned to.We could also just default to making it optional if it is never assigned to at the top level, of course. Then afterwards we can do a check within the constructor to see if it is assigned to.
Additional context
This is tied to #311 , if we have implemented that logic, we can also use that to check whether class fields are actually assigned to. If not, then we make it optional (if it is not already optional)