summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Dygalo <dmitry@dygalo.dev>2021-12-16 19:36:11 +0100
committerDmitry Dygalo <dmitry@dygalo.dev>2021-12-16 19:36:11 +0100
commit7c19bc99679f22f521a24556d8fcfd468fc4104e (patch)
treed6cb326d806563f66fe3540414a7adafe45e7783
parent9f86718f4fa8573dccf5f1c004b977b04ec9a624 (diff)
downloadjsonschema-7c19bc99679f22f521a24556d8fcfd468fc4104e.tar.gz
perf: Replace the `Validator.evolve` method with an equivalent class attribute
-rw-r--r--CHANGELOG.rst1
-rw-r--r--jsonschema/validators.py4
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(