-
-
Notifications
You must be signed in to change notification settings - Fork 799
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
[WIP] Make ManifestSchema compatible with marshmallow >= 3 #3296
Conversation
9dfc3fd
to
eb42f2c
Compare
Instead of suppressing the exception, checking for an error and raising a PlatformIOException, directly raise the PlatformIOException from handle_error(). Add a small wrapper for Schema.load() to cover the the return value difference ((data, error) tuple vs data only). For more information, see https://marshmallow.readthedocs.io/en/stable/upgrading.html
eb42f2c
to
ec931bf
Compare
Could you fix a PR to make it compatible between Python 2 and Python 3? |
Supporting both Python2 and 3 is actually a little bit more work, but I am on it ... |
|
||
from platformio.package.exception import ManifestValidationError | ||
from platformio.util import memoized | ||
|
||
|
||
class StrictSchema(Schema): | ||
def handle_error(self, error, data): | ||
def handle_error(self, error, data, *, _many, **_kwargs): |
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.
Python 2.7 doesn't have keyword only arguments
https://www.python.org/dev/peps/pep-3102/
def handle_error(self, error, data, *, _many, **_kwargs): | |
def handle_error(self, error, data, _many, **_kwargs): |
data, _ = self.load(manifest) | ||
return data | ||
|
||
def handle_error(self, error, data, *, _many, **_kwargs): |
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.
def handle_error(self, error, data, *, _many, **_kwargs): | |
def handle_error(self, error, data, _many, **_kwargs): |
No keyword only arguments in Python 2.7
Sorry for jumping in, just did a quick browse and noticed at least one feature that isn't available in Python 2.7. |
Instead of suppressing the exception, checking for an error and raising
a PlatformIOException, directly raise the PlatformIOException from
handle_error().
Add a small wrapper for Schema.load() to cover the the return value
difference ((data, error) tuple vs data only).
For more information, see
https://marshmallow.readthedocs.io/en/stable/upgrading.html