Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atdpy: to_json and from_json incorrect for aliases of unit #399

Open
kopecs opened this issue Dec 21, 2023 · 0 comments
Open

atdpy: to_json and from_json incorrect for aliases of unit #399

kopecs opened this issue Dec 21, 2023 · 0 comments

Comments

@kopecs
Copy link

kopecs commented Dec 21, 2023

atdpy translates the atd definition

type t = unit

to

@dataclass
class T:
    """Original type: t"""

    value: None

    @classmethod
    def from_json(cls, x: Any) -> 'T':
        return cls(Unit.from_json(x))

    def to_json(self) -> Any:
        return (lambda x: x.to_json())(self.value)

    @classmethod
    def from_json_string(cls, x: str) -> 'T':
        return cls.from_json(json.loads(x))

    def to_json_string(self, **kw: Any) -> str:
        return json.dumps(self.to_json(), **kw)

However, there is no such class Unit as required by the from_json implementation, and None doesn't have a to_json method, as required by to_json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant