-
Notifications
You must be signed in to change notification settings - Fork 5
🚨 Add and check static type hints using mypy #65
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
Changes from all commits
b07c90c
235dc77
64344b6
48f20c3
8120d03
8057659
a6802e1
ada260c
6e49a7b
a69acb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,4 @@ markers = ["datafiles: load datafiles"] | |
| max-line-length = 120 | ||
|
|
||
| [tool.isort] | ||
| line_length = 120 | ||
| line_length = 120 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,16 +3,26 @@ | |
| and corresponding marshmallow schema for de-/serialization | ||
| """ | ||
| # pylint: disable=unused-argument, too-few-public-methods | ||
| from typing import List, Optional | ||
| from typing import List, Optional, Type | ||
|
|
||
| import attr | ||
| from marshmallow import fields, post_load | ||
| from marshmallow_enum import EnumField | ||
| from marshmallow_enum import EnumField # type:ignore | ||
|
|
||
| from bo4e.com.externereferenz import ExterneReferenz, ExterneReferenzSchema | ||
| from bo4e.enum.botyp import BoTyp | ||
| from bo4e.schemata.caseconverterschema import CaseConverterSchema | ||
|
|
||
|
|
||
| def _create_empty_referenzen_list() -> List[ExterneReferenz]: | ||
| """ | ||
| A method with a type hint to please mypy | ||
| https://stackoverflow.com/a/61281305/10009545 | ||
| :return: | ||
| """ | ||
| return [] | ||
|
Comment on lines
+17
to
+23
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not get the connection between this function and the linked SO.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the thing is that the empty list |
||
|
|
||
|
|
||
| @attr.s(auto_attribs=True, kw_only=True) | ||
| class Geschaeftsobjekt: | ||
| """ | ||
|
|
@@ -25,7 +35,7 @@ class Geschaeftsobjekt: | |
|
|
||
| # optional attributes | ||
| externe_referenzen: Optional[List[ExterneReferenz]] = attr.ib( | ||
| default=[], validator=attr.validators.instance_of(List) | ||
| default=_create_empty_referenzen_list(), validator=attr.validators.instance_of(List) # type:ignore | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -36,7 +46,7 @@ class GeschaeftsobjektSchema(CaseConverterSchema): | |
| """ | ||
|
|
||
| # class_name is needed to use the correct schema for deserialization. | ||
| class_name = Geschaeftsobjekt | ||
| class_name: Type[Geschaeftsobjekt] = Geschaeftsobjekt | ||
|
|
||
| # required attributes | ||
| versionstruktur = fields.String() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| """ | ||
| import attr | ||
| from marshmallow import fields, post_load | ||
|
|
||
| from bo4e.com.com import COM, COMSchema | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| """ | ||
| import attr | ||
| from marshmallow import fields, post_load | ||
|
|
||
| from bo4e.com.com import COM, COMSchema | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to check the enum topic again. I think they are not well implemented.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific line the problem is the marshmallow_enum package itself.