-
Notifications
You must be signed in to change notification settings - Fork 329
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
v201:call,call_result,datatypes: complete and corrected type annotations #562
v201:call,call_result,datatypes: complete and corrected type annotations #562
Conversation
I think this change is a superset of #529 and contains all of those fixes. |
ea3d8ca
to
b729d04
Compare
The PR contains at least a serious fix to total_cost type, which is a showstopper at implementing an OCPP2 server compliant with pricing regulation with that library. The rest of PR is also refining properly a bunch of types definition. |
9ab973a
to
534be5d
Compare
I rebased this so it will merge cleanly with |
534be5d
to
d9d06e4
Compare
@OrangeTux, @Jared-Newell-Mobility, @jainmohit2001: is there a chance that trivial PRs such as that one making the developer experience way more comfortable while enforcing strong types get reviewed and merged? |
d9d06e4
to
6be51ec
Compare
HI @malsyned, can you help with the following question? @on(Action.Authorize)
async def on_authorize(self, id_token: dict, *args, **kwargs):
status = AuthorizationStatusType.accepted
return call_result.Authorize(id_token_info={"status": status}) Currently we have the following signature for Authorize dataclass: @dataclass
class Authorize:
id_token_info: Dict
certificate_status: Optional[str] = None
custom_data: Optional[Dict[str, Any]] = None What would happen when we change the signature of Authorize to the following: @dataclass
class Authorize:
id_token: datatypes.IdTokenType
certificate: Optional[str] = None
iso15118_certificate_hash_data: Optional[List[datatypes.OCSPRequestDataType]] = None
custom_data: Optional[Dict[str, Any]] = None Do I need to make any changes to my |
@jainmohit2001 I don't think you would have to make any changes, but I haven't looked at this in a while. I was working on an experimental @on-style decorator that uses these more specific type signatures to create ocpp objects, but as the library works now, the handler just receives a dictionary, and that shouldn't change because of this PR. |
@malsyned while i fully support including this pull request in the library as your changes now match the json schemas, it could be a breaking change, depending on how the caller of their handlers marshal the OCPP message into the payload. @jainmohit2001
if the payload is hydrated recursively -- using a library such as
@jainmohit2001 |
There's already release candidates in progress for the 2.0.0 release, the first version to include ocpp v2 support. And breaking changes in major revision rcs are totally fine. The only question remaining is: do the maintainers want to make the dev experience way more comfortable and strongly typed or not? |
@malsyned i opened up a pull request against your branch to fix the linting errors and bring it up-to-date with base branch. hopefully this streamlines things instead of opening another pull request against the main fork. |
@jerome-benoit I just opened #684 to create a unit test that verifies no functionality changes happen with the nested dataclasses. I opened a new PR with the datatype changes #680 which includes the same unit test. could you review both and give feedback? the project recently changed ownership from company-backed to volunteer lead so I'm hopeful that the new maintainers will be able to address a few outstanding PRs. @malsyned could you review the new PRs as well? would be great to have your feedback as well since you've been involved with the nested dataclass changes. is there anything else we can do to show that these aren't breaking changes? |
Looks like there are some issues with Black. Can you update this PR? |
Closing this PR as completed in #680 |
I groveled through the v2.0.1 spec and updated all of the type signatures to be complete and accurate to the best of my ability.
I did this to support some work I'm doing to make a variant of
@on
that converts the JSON back to Python objects, but I think it will be useful to anyone using the library with an IDE, so I'm submitting it as a separate pull request.