summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Knight <nknight@siaras.com>2016-09-02 13:59:54 -0700
committerJan Willhaus <mail@janwillhaus.de>2019-11-02 22:02:37 +0100
commit375c75369df54e8e47fe41b3284a50fcc1ae6b03 (patch)
tree908350b6eb351bbfb683c8fd012247bedde296b2
parent151a3f5f49874c931376874355cc5f4fc502c877 (diff)
downloadwarlock-375c75369df54e8e47fe41b3284a50fcc1ae6b03.tar.gz
Undo changes to the `warlock.model_factory` API
The changes introduced by commit 64a771d151a5defb9bca82042f ("Allow resolver to be set on the Model") added a new keyword argument to the `warlock.model_factory` function. Due to the way Python handles positional arguments, the change alters the way that existing code is interpreted. Before the change, warlock.model_factory(schema_arg, snd_pos_arg) would execute with kwargs == { 'base_class': snd_pos_arg, 'name': None, } but after the change it's interpreted as kwargs == { 'resolver': snd_pos_arg, 'base_class'=model.Model, 'name': None, } This commit re-arranges the arguments to restore the previous behaviour in an effort to not break existing code.
-rw-r--r--tests/test_core.py4
-rw-r--r--warlock/core.py2
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index daa458c..923d94f 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -260,8 +260,8 @@ class TestCore(unittest.TestCase):
country_schema = json.load(country_schema_file)
person_schema = json.load(person_schema_file)
- Country = warlock.model_factory(country_schema, resolver)
- Person = warlock.model_factory(person_schema, resolver)
+ Country = warlock.model_factory(country_schema, resolver=resolver)
+ Person = warlock.model_factory(person_schema, resolver=resolver)
england = Country(
name="England",
diff --git a/warlock/core.py b/warlock/core.py
index 621b0a8..a6dd3a4 100644
--- a/warlock/core.py
+++ b/warlock/core.py
@@ -19,7 +19,7 @@ import copy
from . import model
-def model_factory(schema, resolver=None, base_class=model.Model, name=None):
+def model_factory(schema, base_class=model.Model, name=None, resolver=None):
"""Generate a model class based on the provided JSON Schema
:param schema: dict representing valid JSON schema