Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dict when validate assignment true #1024

Conversation

austinpgraham
Copy link
Contributor

@austinpgraham austinpgraham commented Dec 21, 2023

Issue reported here.

This PR fixes an issue with v1.1.0 where setting validate_assignment = True on a Schema throws an Attribute error for dict on DjangoGetter. Example, from added test with change removed to force the error:

FAILED tests/test_schema.py::test_django_getter_validates_assignment - AttributeError: 'DjangoGetter' object has no attribute '__dict__'

It appears this functionality was broken when GetterDict was removed as a parent from DjangoGetter, and adding dict in slots seems to be the easiest fix.

I'm very open to feedback, and if this is intended or what a better fix might be, this PR is just me taking a stab at fixing something needed by my company.

Note: It appears running the linting fixed a couple other linting issues unrelated to this change.

@vitalik
Copy link
Owner

vitalik commented Dec 21, 2023

Hi @austinpgraham

Thank you

could you reformat some code-style changes with

pip install -U ruff
ruff format ninja tests

@austinpgraham
Copy link
Contributor Author

Done, thanks @vitalik

@vitalik vitalik merged commit d913952 into vitalik:master Dec 28, 2023
27 checks passed
@sandro-encora
Copy link

@vitalik Any plans on releasing a new version with this fix? Thank you!

@bastiaan85
Copy link

@vitalik +1 for me too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants