diff options
author | Dmitry Dygalo <dmitry@dygalo.dev> | 2021-12-16 19:36:11 +0100 |
---|---|---|
committer | Dmitry Dygalo <dmitry@dygalo.dev> | 2021-12-16 19:36:11 +0100 |
commit | 7c19bc99679f22f521a24556d8fcfd468fc4104e (patch) | |
tree | d6cb326d806563f66fe3540414a7adafe45e7783 | |
parent | 9f86718f4fa8573dccf5f1c004b977b04ec9a624 (diff) | |
download | jsonschema-7c19bc99679f22f521a24556d8fcfd468fc4104e.tar.gz |
perf: Replace the `Validator.evolve` method with an equivalent class attribute
-rw-r--r-- | CHANGELOG.rst | 1 | ||||
-rw-r--r-- | jsonschema/validators.py | 4 |
2 files changed, 2 insertions, 3 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a57e5ba..2ca1346 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ v4.3.0 certain input types (#893) * Cache reference lookups for subschemas (#893) * Use cached lookups for resolving fragments if the referent document is known (#893) +* Replace the ``Validator.evolve`` method with an equivalent class attribute * Implement a PEP544 Protocol for validator classes (#890) v4.2.1 diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 93c2929..936d723 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -169,6 +169,7 @@ def create( schema = attr.ib(repr=reprlib.repr) resolver = attr.ib(default=None, repr=False) format_checker = attr.ib(default=None) + evolve = attr.evolve def __attrs_post_init__(self): if self.resolver is None: @@ -182,9 +183,6 @@ def create( for error in cls(cls.META_SCHEMA).iter_errors(schema): raise exceptions.SchemaError.create_from(error) - def evolve(self, **kwargs): - return attr.evolve(self, **kwargs) - def iter_errors(self, instance, _schema=None): if _schema is not None: warnings.warn( |