Skip to content

Commit

Permalink
Use type check instead duck-typing
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Jun 22, 2019
1 parent 7062102 commit 6ec36d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions flask_apispec/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# -*- coding: utf-8 -*-
try:
from collections.abc import Mapping
except ImportError: # Python 2
from collections import Mapping

from six.moves import http_client as http

import flask

import marshmallow as ma
import werkzeug
from six.moves import http_client as http
from webargs import flaskparser

from flask_apispec import utils

import marshmallow as ma

MARSHMALLOW_VERSION_INFO = tuple(
[int(part) for part in ma.__version__.split('.') if part.isdigit()]
Expand Down Expand Up @@ -43,7 +46,7 @@ def call_view(self, *args, **kwargs):
parsed = parser.parse(schema, locations=option['kwargs']['locations'])
if getattr(schema, 'many', False):
args += tuple(parsed)
elif getattr(parsed, 'update', False):
elif isinstance(parsed, Mapping):
kwargs.update(parsed)
else:
args += (parsed, )
Expand Down
3 changes: 3 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class User:
def __init__(self, name):
self.name = name

def update(self, name):
self.name = name

class ArgSchema(Schema):
name = fields.Str()

Expand Down

0 comments on commit 6ec36d3

Please sign in to comment.