Skip to content

Commit ff17255

Browse files
Tim O'FarrellTim O'Farrell
Tim O'Farrell
authored and
Tim O'Farrell
committed
Blackened
1 parent 3ab780f commit ff17255

File tree

7 files changed

+48
-34
lines changed

7 files changed

+48
-34
lines changed

injecty_config_schemey/__init__.py

+35-24
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
from schemey.factory.impl_schema_factory import ImplSchemaFactory
1212
from schemey.factory.ref_schema_factory import RefSchemaFactory
1313
from schemey.factory.schema_factory_abc import SchemaFactoryABC
14-
from schemey.factory.simple_type_factory import BoolTypeFactory, IntTypeFactory, NoneTypeFactory, FloatFactory, \
15-
StrFactory
14+
from schemey.factory.simple_type_factory import (
15+
BoolTypeFactory,
16+
IntTypeFactory,
17+
NoneTypeFactory,
18+
FloatFactory,
19+
StrFactory,
20+
)
1621
from schemey.factory.tuple_schema_factory import TupleSchemaFactory
1722
from schemey.factory.uuid_factory import UuidFactory
1823
from schemey.json_schema.ranges_validator import RangesValidator
@@ -25,26 +30,32 @@
2530

2631
def configure(context: InjectyContext):
2732
context.register_impl(MarshallerABC, SchemaMarshaller)
28-
context.register_impls(SchemaFactoryABC, [
29-
RefSchemaFactory,
30-
BoolTypeFactory,
31-
IntTypeFactory,
32-
NoneTypeFactory,
33-
FloatFactory,
34-
StrFactory,
35-
DatetimeFactory,
36-
UuidFactory,
37-
ArraySchemaFactory,
38-
TupleSchemaFactory,
39-
ExternalTypeFactory,
40-
DataclassSchemaFactory,
41-
EnumSchemaFactory,
42-
FactorySchemaFactory,
43-
ImplSchemaFactory,
44-
AnyOfSchemaFactory,
45-
])
33+
context.register_impls(
34+
SchemaFactoryABC,
35+
[
36+
RefSchemaFactory,
37+
BoolTypeFactory,
38+
IntTypeFactory,
39+
NoneTypeFactory,
40+
FloatFactory,
41+
StrFactory,
42+
DatetimeFactory,
43+
UuidFactory,
44+
ArraySchemaFactory,
45+
TupleSchemaFactory,
46+
ExternalTypeFactory,
47+
DataclassSchemaFactory,
48+
EnumSchemaFactory,
49+
FactorySchemaFactory,
50+
ImplSchemaFactory,
51+
AnyOfSchemaFactory,
52+
],
53+
)
4654

47-
context.register_impls(SchemaValidatorABC, [
48-
RangesValidator,
49-
TimestampValidator,
50-
])
55+
context.register_impls(
56+
SchemaValidatorABC,
57+
[
58+
RangesValidator,
59+
TimestampValidator,
60+
],
61+
)

schemey/factory/dataclass_schema_factory.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ def from_json(
9595
)
9696
default = field_item.get("default", dataclasses.MISSING)
9797
if default is not dataclasses.MISSING:
98-
default = context.marshy_context.load(
99-
field_schema.python_type, default
100-
)
98+
default = context.marshy_context.load(field_schema.python_type, default)
10199
p = params_with_default
102100
else:
103101
p = params

schemey/factory/impl_schema_factory.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class ImplSchemaFactory(SchemaFactoryABC):
1616
structure - though the UnionFactory will make a reasonably standardized class
1717
structure from the result.
1818
"""
19+
1920
priority: int = 150
2021

2122
def from_type(
@@ -26,7 +27,9 @@ def from_type(
2627
ref_schemas: Dict[Type, Schema],
2728
) -> Optional[Schema]:
2829
# noinspection PyTypeChecker
29-
impls = context.marshy_context.injecty_context.get_impls(type_, permit_no_impl=True)
30+
impls = context.marshy_context.injecty_context.get_impls(
31+
type_, permit_no_impl=True
32+
)
3033
if impls:
3134
impls = sorted(list(impls), key=lambda i: i.__name__)
3235
any_of = []

schemey/json_schema/ranges_validator.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RangesValidator(SchemaValidatorABC):
2222
}]
2323
}
2424
"""
25+
2526
property_name: str = "ranges"
2627

2728
def validate(self, validator, aP, instance, schema):

schemey/json_schema/schema_validator_abc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ class SchemaValidatorABC(ABC):
55
property_name: str
66

77
def validate(self, validator, aP, instance, schema):
8-
""" Validate this property """
8+
"""Validate this property"""

schemey/schema.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ def validator(self, injecty_context: InjectyContext = None):
2525
validator = validator_for(self.schema)(
2626
schema=self.schema, format_checker=SchemeyFormatChecker()
2727
)
28-
validator.VALIDATORS.update({
29-
instance.property_name: instance.validate
30-
for instance in injecty_context.get_instances(SchemaValidatorABC)
31-
})
28+
validator.VALIDATORS.update(
29+
{
30+
instance.property_name: instance.validate
31+
for instance in injecty_context.get_instances(SchemaValidatorABC)
32+
}
33+
)
3234
return validator
3335

3436
def iter_errors(self, item: ExternalType) -> Iterator[ValidationError]:

schemey/schema_context.py

-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,3 @@ def create_schema_context(
6767
marshy_context=marshy_context,
6868
)
6969
return context
70-

0 commit comments

Comments
 (0)