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

cattrs does not consider 'alias' argument for field function in attrs. #362

Closed
ranjithvuppala opened this issue May 8, 2023 · 2 comments

Comments

@ranjithvuppala
Copy link

  • cattrs version: 2022.2.0
  • Python version: py-3.11
  • Operating System: Windows 10

Description

when using structure_attrs_fromdict cattrs doesnot honour 'alias' name for the field..

For example:

@define
class Dummy:
    key1: str
    key3: str = field(alias="key2")

input_dict = {"key1": "test1", "key2": "test3"}
cattrs.structure_attrs_fromdict(b, Dummy)

Should work. But it gives this error

TypeError: Dummy.__init__() missing 1 required positional argument: 'key2'

Where as creating attrs class direclty works
instance = Dummy(key1 = "value1", key2="value2")

@Tinche
Copy link
Member

Tinche commented May 8, 2023

Hello,

closing as dupe of #322. Haven't gotten around to it yet!

@ranjithvuppala
Copy link
Author

closed in favour of #322

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

2 participants