-
-
Notifications
You must be signed in to change notification settings - Fork 610
Description
The failing code is here:
https://github.com/p1c2u/openapi-schema-validator/blob/4d8fd4c2bddce50931ea617bca54d526ae0535cd/openapi_schema_validator/validators.py#L78-L96
It does look very strange that the new evolve method doesn't keep the attributes of the OAS30Validator class.
There they have an @attrs class. It defines a read and write attribute. And after evolving, not only are the read and write attributes gone, but super calls as line 96 don't work either.
I have also made an issue in their project: python-openapi/openapi-schema-validator#46
I am not sure which one of the projects should update. But I feel that this new evolve method only does half of what it used to do and is not good enough to replace an attrs.evolve
jsonschema/jsonschema/validators.py
Lines 204 to 216 in ae0feea
| def evolve(self, **changes): | |
| schema = changes.setdefault("schema", self.schema) | |
| NewValidator = validator_for(schema, default=Validator) | |
| # Essentially reproduces attr.evolve, but may involve instantiating | |
| # a different class than this one. | |
| for field in attr.fields(Validator): | |
| if not field.init: | |
| continue | |
| attr_name = field.name # To deal with private attributes. | |
| init_name = attr_name if attr_name[0] != "_" else attr_name[1:] | |
| if init_name not in changes: | |
| changes[init_name] = getattr(self, attr_name) |