From 0c6fa36f45a676fb7abbef49d2a5f6196e5a08c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta?= Date: Tue, 18 Jun 2024 10:37:51 +0200 Subject: [PATCH] run black --- python_jsonschema_objects/classbuilder.py | 32 ++++++++++++---------- python_jsonschema_objects/util.py | 2 -- python_jsonschema_objects/wrapper_types.py | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/python_jsonschema_objects/classbuilder.py b/python_jsonschema_objects/classbuilder.py index 367f070..bb01230 100644 --- a/python_jsonschema_objects/classbuilder.py +++ b/python_jsonschema_objects/classbuilder.py @@ -216,11 +216,11 @@ def __init__(self, **props): import sys e = type(e)( - str(e) - + " \nwhile setting '{0}' in {1}".format( - prop, self.__class__.__name__ - ) + str(e) + + " \nwhile setting '{0}' in {1}".format( + prop, self.__class__.__name__ ) + ) raise e.with_traceback(sys.exc_info()[2]) if getattr(self, "__strict__", None): @@ -638,13 +638,15 @@ def _build_literal(self, nm, clsdata): # This weird value on the next line is a sentinel value, because we can't use the standard `get( # "key", None) is not None` motif because sometimes the value is None. If someone has an actual # value like this (which I generated by having my cat walk on my keyboard), they're out of luck. - "__default__": clsdata["default"] - if clsdata.get( - "default", - "asldkfn24olkjalskdfn e;laishd;1loj;flkansd;iow;naosdinfe;lkamjsdfj", - ) - is not "asldkfn24olkjalskdfn e;laishd;1loj;flkansd;iow;naosdinfe;lkamjsdfj" - else clsdata.get("const"), + "__default__": ( + clsdata["default"] + if clsdata.get( + "default", + "asldkfn24olkjalskdfn e;laishd;1loj;flkansd;iow;naosdinfe;lkamjsdfj", + ) + is not "asldkfn24olkjalskdfn e;laishd;1loj;flkansd;iow;naosdinfe;lkamjsdfj" + else clsdata.get("const") + ), } }, ) @@ -820,9 +822,11 @@ def _build_object(self, nm, clsdata, parents, **kw): def construct_objects(self, oneOfList, uri): return [ - self.construct(uri + "_%s" % i, item_detail) - if "$ref" not in item_detail - else self.resolve_type(item_detail["$ref"], uri + "_%s" % i) + ( + self.construct(uri + "_%s" % i, item_detail) + if "$ref" not in item_detail + else self.resolve_type(item_detail["$ref"], uri + "_%s" % i) + ) for i, item_detail in enumerate(oneOfList) ] diff --git a/python_jsonschema_objects/util.py b/python_jsonschema_objects/util.py index cd27137..1b67fc1 100644 --- a/python_jsonschema_objects/util.py +++ b/python_jsonschema_objects/util.py @@ -7,7 +7,6 @@ from collections.abc import Mapping, Sequence - class lazy_format(object): __slots__ = ("fmt", "args", "kwargs") @@ -35,7 +34,6 @@ def safe_issubclass(x, y): return False - class ProtocolJSONEncoder(json.JSONEncoder): def default(self, obj): from python_jsonschema_objects import classbuilder, wrapper_types diff --git a/python_jsonschema_objects/wrapper_types.py b/python_jsonschema_objects/wrapper_types.py index e293086..59f5cb9 100644 --- a/python_jsonschema_objects/wrapper_types.py +++ b/python_jsonschema_objects/wrapper_types.py @@ -186,9 +186,7 @@ def validate_items(self): elif util.safe_issubclass(typ, classbuilder.ProtocolBase): if not isinstance(elem, typ): try: - if isinstance( - elem, (str, int, float) - ): + if isinstance(elem, (str, int, float)): val = typ(elem) else: val = typ(**elem)