-
Notifications
You must be signed in to change notification settings - Fork 317
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
base: master
Are you sure you want to change the base?
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. |
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.