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

Enable type checks for nethsm code #32

Closed
nponsard opened this issue Sep 29, 2023 · 0 comments · Fixed by #44
Closed

Enable type checks for nethsm code #32

nponsard opened this issue Sep 29, 2023 · 0 comments · Fixed by #44
Assignees

Comments

@nponsard
Copy link
Contributor

nponsard commented Sep 29, 2023

Transferred from Nitrokey/pynitrokey#442 :

The updated NetHSM API client includes type annotations so we should be able to remove this exception:

[[tool.mypy.overrides]]
module = "nethsm.client.*"
ignore_errors = true

And maybe also add the module to the strict checks:

[[tool.mypy.overrides]] 
module = [ 
 "nethsm.client.*",
]
disallow_untyped_defs = true 

A quick test causes a few error messages though:

pynitrokey/nethsm/client/paths/keys_generate/post/responses/response_201/__init__.py:19: error: Attributes without a default cannot follow attributes with one  [misc]
pynitrokey/nethsm/client/paths/keys/post/responses/response_201/__init__.py:19: error: Attributes without a default cannot follow attributes with one  [misc]
pynitrokey/nethsm/client/components/schema/public_key.py:78: error: Incompatible types in assignment (expression has type "str", variable has type "Union[Mapping[str, Union[dict[Any, Any], immutabledict[Any, Any], Mapping[str, object], list[Any], tuple[Any, ...], float, int, str, date, datetime, UUID, bool, None, bytes, io.FileIO, BufferedReader, pynitrokey.nethsm.client.schemas.schema.FileIO]], KeyPublicDataDict, Unset]")  [assignment]
pynitrokey/nethsm/client/components/schema/public_key.py:83: error: Invalid index type "Union[Mapping[str, Union[dict[Any, Any], immutabledict[Any, Any], Mapping[str, object], list[Any], tuple[Any, ...], float, int, str, date, datetime, UUID, bool, None, bytes, io.FileIO, BufferedReader, pynitrokey.nethsm.client.schemas.schema.FileIO]], KeyPublicDataDict, Unset]" for "dict[str, Any]"; expected type "str"  [index]
pynitrokey/nethsm/client/components/schema/private_key.py:73: error: Incompatible types in assignment (expression has type "str", variable has type "Union[Mapping[str, Union[dict[Any, Any], immutabledict[Any, Any], Mapping[str, object], list[Any], tuple[Any, ...], float, int, str, date, datetime, UUID, bool, None, bytes, io.FileIO, BufferedReader, pynitrokey.nethsm.client.schemas.schema.FileIO]], KeyPrivateDataDict]")  [assignment]
pynitrokey/nethsm/client/components/schema/private_key.py:78: error: Invalid index type "Union[Mapping[str, Union[dict[Any, Any], immutabledict[Any, Any], Mapping[str, object], list[Any], tuple[Any, ...], float, int, str, date, datetime, UUID, bool, None, bytes, io.FileIO, BufferedReader, pynitrokey.nethsm.client.schemas.schema.FileIO]], KeyPrivateDataDict]" for "dict[str, Any]"; expected type "str"  [index]

And the generated code still has many untyped defs.

Issue created on the generator repo : openapi-json-schema-tools/openapi-json-schema-generator#246

robin-nitrokey added a commit that referenced this issue Oct 17, 2023
This patch enables strict mypy checks for the nethsm modules that
contains the code that we wrote manually.

Fixes: #32
robin-nitrokey added a commit that referenced this issue Oct 18, 2023
This patch enables strict mypy checks for the nethsm modules that
contains the code that we wrote manually as well as some refactoring
that is necessary to pass these checks.

Fixes: #32
robin-nitrokey added a commit that referenced this issue Oct 18, 2023
This patch enables strict mypy checks for the nethsm modules that
contains the code that we wrote manually as well as some refactoring
that is necessary to pass these checks.

Fixes: #32
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.

2 participants