feat: Add correct types and make mypy --strict pass - #771
fjovell-swish wants to merge 3 commits into
Conversation
eb15a94 to
67241b9
Compare
|
The only issue I found is with v201/enums.py which mypy for some reason cannot handle. To mitigate this, I excluded the files and disallowed following imports. Reported here: python/mypy#21902 |
|
Nice initiative! Some considerations:
|
7ea514d to
e59e918
Compare
Apparently, I was wrong. There's nothing wrong with mypy, we are just reasigning the "count" identifier from a callable to a string and thus it is raising a completely valid error. Instead, I added type ignore to these lines, and removed the configuration for ignoring files, and skipping following imports. |
|
@a-alak While your considerations are very reasonable I think they are out of scope for this PR. |
|
Sure, just thought those will be relevant decisions to take and PRs to make, if there is a decision to make this library support static typing. |
|
Certainly, not saying otherwise. At the very least, I added the mypy check into the Makefile which also checks for formatting, linting, and runs the tests. |
|
Thanks for this, it's a solid start. I ran Blocking1.
from ocpp.exceptions import NotImplementedError, FormatViolationError
e = NotImplementedError()
e.details["x"] = 1
FormatViolationError().details # {'x': 1}Previously each instance got a fresh def __init__(
self,
description: Optional[str] = None,
details: Optional[Dict[str, Any]] = None,
):
self.description = (
description if description is not None else self.default_description
)
self.details = details if details is not None else {}The 2. Shipping
Either fix these, or hold back Non-blocking
|
e59e918 to
48d57ca
Compare
|
Hello, @mdwcrft. Thank you for your review. I implemented all the suggested changes in the last commit. However, there's the issue about the Regarding the |
bcb459b to
137acf6
Compare
Changes included in this PR
Adds correct type annotations to the whole codebase.
Impact
Describe breaking changes, including changes a users might need to make due to this PR
Checklist