-
Notifications
You must be signed in to change notification settings - Fork 339
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
Add arg skip_schema_validation
to @on()
#56
Conversation
DeepCode Report (#e4122f)DeepCode analyzed this pull request. |
The argument can be used to skip validation of a request and response. It defaults to `False`, so by default validation is enabled. The reasoning for this change is that TMH has charge points which use measurands inside MeterValues messages which are not compliant with the OCPP 1.6 specification. Therefore the validation of these messages fail. With this new argument validation of certain messages can be disabled. Fixes: #54
43c6551
to
41479e7
Compare
@@ -1,7 +1,7 @@ | |||
import functools | |||
|
|||
|
|||
def on(action): | |||
def on(action, *, skip_schema_validation=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the asterisk come into play?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All arguments after the aterisk can only used with as keyword arguments.
So the following call would raise a TypeError:
def foo(*, a):
pass
foo(1) # will raise a TypeError
Instead it is required to use keyword arguments:
foo(a=1) # works fine
Without aterisk the @on()
decorator could be used like this:
@on("MeterValues", True)
def on_meter_values(*args, **kwargs):
pass
Without the keyword it is hard to guess what the meaning is of the second argument. I added the aterisk to make it explicit to disable validation. You can either use skip_schema_validation
s default value of False
. Or, if you want to disable the validation, you can set it to true by keyword arguments:
@on("MeterValues", skip_schema_validation=True)
def on_meter_values(*args, **kwargs):
pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Thanks for the explanation.
The argument can be used to skip validation of a request and response.
It defaults to
False
, so by default validation is enabled.The reasoning for this change is that TMH has charge points which use
measurands inside MeterValues messages which are not compliant with the
OCPP 1.6 specification. Therefore the validation of these messages fail.
With this new argument validation of certain messages can be disabled.
Fixes: #54