Improve type hints #96
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry for the massive PR 👀
Summary
The aim of this PR is to improve type hints. #95
Fixing some typing errors as well as adding generics
I used Pyright for type checking. I commited the pyrightconfig.json so my config can be duplicated.
In most places, I could not deduce the correct generics, so Any is used liberally.
Moving forward these could slowly be made more specific.
Behavioral Changes
I did my best to avoid making behavior changes in 99% of cases.
There are a few cases where I introduced changes that could modify behavior. Here are a few:
paddle_billing/Entities/Notifications/NotificationEvent.py:45 -> raise error
paddle_billing/Notifications/Verifier.py:53 -> raise error
paddle_billing/ResponseParser.py:
Two methods were added:
get_listandget_dict.Both of these are just wrappers for
get_databut with the correct type annotations.get_dictwill still return a list fromget_dataif thebodyis None. This should probably be looked at.paddle_billing/Notifications/Entities/Entity.py & paddle_billing/Notifications/Entities/Simulations/SimulationEntity.py
Added
type(entity_class) is not type.Open to any feedback also.