-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type error from field with attributes
This commit fixes pyright type error from field with attributes. You still get type error with mypy v1.8.0 as mypy still does not fully support dataclass_transform ``` from dataclasses import dataclass from serde import serde, field @serde @DataClass class Foo: id: int = field(rename="ID") comments: str ```
- Loading branch information
Showing
3 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from dataclasses import dataclass | ||
from serde import serde, field | ||
|
||
|
||
@serde | ||
@dataclass | ||
class Foo: | ||
id: int = field(rename="ID") # Field with attributes can be defined before other fields | ||
# thanks to dataclass_transform field_specifiers | ||
# https://peps.python.org/pep-0681/#the-dataclass-transform-decorator | ||
# NOTE: you still get error with mypy as of mypy v1.8.0 | ||
comments: str | ||
|
||
|
||
if __name__ == "__main__": | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters