Skip to content

Commit

Permalink
Handle warning in metadata test; remove unnecessary 'type: ignore's (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Mar 30, 2021
1 parent 1776680 commit b5a0300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def get_lowername(obj):

class UserSchema(Schema):
name = fields.String()
age = fields.Float()
age = fields.Float() # type: fields.Field
created = fields.DateTime()
created_formatted = fields.DateTime(
format="%Y-%m-%d", attribute="created", dump_only=True
Expand All @@ -168,7 +168,7 @@ class UserSchema(Schema):
homepage = fields.Url()
email = fields.Email()
balance = fields.Decimal()
is_old = fields.Method("get_is_old")
is_old = fields.Method("get_is_old") # type: fields.Field
lowername = fields.Function(get_lowername)
registered = fields.Boolean()
hair_colors = fields.List(fields.Raw)
Expand Down Expand Up @@ -267,15 +267,15 @@ class Meta:


class UserIntSchema(UserSchema):
age = fields.Integer() # type: ignore
age = fields.Integer()


class UserFloatStringSchema(UserSchema):
age = fields.Float(as_string=True)


class ExtendedUserSchema(UserSchema):
is_old = fields.Boolean() # type: ignore
is_old = fields.Boolean()


class UserRelativeUrlSchema(UserSchema):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ class Meta:
class TestMetadata:
@pytest.mark.parametrize("FieldClass", ALL_FIELDS)
def test_extra_metadata_may_be_added_to_field(self, FieldClass): # noqa
field = FieldClass(description="Just a normal field.")
with pytest.warns(DeprecationWarning):
field = FieldClass(description="Just a normal field.")
assert field.metadata["description"] == "Just a normal field."
field = FieldClass(
required=True,
Expand Down

0 comments on commit b5a0300

Please sign in to comment.