Fable
Fable copied to clipboard
`createEmpty` code fails at runtime when targeting python
I don't know if createEmpty
is expected to work the same in Python as in JavaScript but currently I get an error when trying to run the code.
Description
open Fable.Core
open Fable.Core.PyInterop
type IUser =
abstract Name : string with get, set
abstract Age : int with get, set
let user = createEmpty<IUser>
user.Name <- "Kaladin"
user.Age <- 20
generates
from __future__ import annotations
from abc import abstractmethod
from typing import Protocol
class IUser(Protocol):
@property
@abstractmethod
def Age(self) -> int:
...
@Age.setter
@abstractmethod
def Age(self, __arg0: int) -> None:
...
@property
@abstractmethod
def Name(self) -> str:
...
@Name.setter
@abstractmethod
def Name(self, __arg0: str) -> None:
...
user: IUser = None
user.Name = "Kaladin"
user.Age = 20
When running the code I have this error:
> python3 program.py
Traceback (most recent call last):
File "/Users/mmangel/Downloads/testNodeFable/program.py", line 29, in <module>
user.Name = "Kaladin"
^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'Name'
Related information
- Fable version: 4.1.4
- Operating system