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

Inconsistent Behavior with Object Translation and .transmute() #64

Closed
seandstewart opened this issue Apr 28, 2020 · 0 comments · Fixed by #65
Closed

Inconsistent Behavior with Object Translation and .transmute() #64

seandstewart opened this issue Apr 28, 2020 · 0 comments · Fixed by #65

Comments

@seandstewart
Copy link
Owner

  • typical version: 2.0.5
  • Python version: 3.7
  • Operating System: macos

Description

Translation between higher-order objects isn't behaving properly when signatures don't exactly align.

Additionally, calling .transmute() on data with unknown fields fails, but should succeed.

What I Did

import typic
from typing import Optional


@typic.klass
class Source:
    test: Optional[str] = typic.field(init=False)
    field_to_ignore: str = "Ignore me"
    def __post_init__(self):
        self.test = "Something"


@typic.klass
class Dest:
    test: Optional[str] = None


Dest.transmute(Source())
# => throws "Source is missing fields: ('test',)"

Dest.transmute(Source().primitive())
# => throws "TypeError: __init__() got an unexpected keyword argument 'field_to_ignore'"
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

Successfully merging a pull request may close this issue.

1 participant