Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Fix for marshmallow 3.0.0rc7 #29

Merged
merged 4 commits into from
Aug 21, 2019
Merged

Fix for marshmallow 3.0.0rc7 #29

merged 4 commits into from
Aug 21, 2019

Conversation

svidela
Copy link
Contributor

@svidela svidela commented Jun 19, 2019

  • fix needed for marshmallow >= 3.0.0rc7
  • fix tests for marshmallow >= 3.0.0
  • avoid deprecation warnings
  • adds tox environments for python 3.7, marshmallow<3.0.0 and marshmallow>=3.0.0rc7

@svidela svidela mentioned this pull request Jun 24, 2019
@aberres
Copy link

aberres commented Jul 1, 2019

Just wanted to provide the same compatibility fix 👍

@@ -38,7 +38,7 @@ def __init__(
self.enum = enum
self.by_value = by_value

if error and any(old in error for old in ('{name', '{value', '{choices')):
if error and any(old in error for old in ('name}', 'value}', 'choices}')):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? These are library specific interpolations and not dependent on marshmallow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it because as it was before I would always get the warning. Even when using the not deprecated interpolations. But, I just noticed that the pytest version should be >= 3.8.0, otherwise I'm not getting any warnings. Could you confirm this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check it out. The issue with checking for the } at the end is there could be formatting directives in between the the target and the end of the interpolation.

@@ -51,7 +51,7 @@ def __init__(
if load_by is None:
load_by = LoadDumpOptions.value if by_value else LoadDumpOptions.name

if load_by not in LoadDumpOptions:
if not isinstance(load_by, Enum) or load_by not in LoadDumpOptions:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be not isinstance(load_by, LoadDumpOptions) but the not in check should be good enough, what's the reasoning behind this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aim was to avoid this warning (shown with pytest >= 3.8.0):

DeprecationWarning: using non-Enums in containment checks will raise TypeError in Python 3.8
  if load_by not in LoadDumpOptions:

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't realize that was a change coming. Carry on. 👌

@@ -75,13 +77,19 @@ class EnumSchema(Schema):

def test_enum_field_load(self):
serializer = self.EnumSchema()
data = serializer.load({'enum': 'one', 'none': None}).data

data = serializer.load({'enum': 'one'})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would rather either:

  1. Drop support for Marshmallow 2 and ergo not need this check (would require a major version bump)
  2. Write separate tests that use pytest.skipif to avoid introducing versioning checks in the tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for option 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! should I move forward with option 1?

@stefanvanburen
Copy link

any chance we can get this merged? would love to upgrade to marshmallow v3 - seems like this is our only blocker. thanks for all the work!

@justanr
Copy link
Owner

justanr commented Aug 20, 2019

I'll do one more review and merge if I don't see anything that's serious when I get home from work today.

@justanr justanr merged commit 7b81ea6 into justanr:master Aug 21, 2019
@justanr
Copy link
Owner

justanr commented Aug 21, 2019

Didn't forget to smash that approve and merge button tonight.

@justanr
Copy link
Owner

justanr commented Aug 21, 2019

v1.5.1 is now live (1.5.1 because pypi added the strict ReST requirement for readmes since last release 😬 )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants