-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
user_passes_test
should take in AUTH_USER_MODEL
#1058
Comments
user_passes_test
should take in AUTH_USER_MODEL
Nice idea. One thing to note: it should replace with |
Yes, I'm working on a fix for this. Edit: it might be actually more complicated, as I'm not sure how the mypy api allows overriding the type information of a decorator. |
A way to solve this might be changing the way we handle |
with the release of 1.13.0, I imagine more people are likely to find this issue. Is there a sensible way to annotate my code so that django-stubs does not complain? |
Add a transformer that updates the signature of user_passes_test to reflect settings.AUTH_USER_MODEL. Fixes typeddjango#1058
Add a transformer that updates the signature of user_passes_test to reflect settings.AUTH_USER_MODEL. Fixes typeddjango#1058
@PIG208 Are you willing to PR your suggested behavior? |
I've also stumbled upon this... I've got this decorator: def any_permission_required(*args):
return user_passes_test(lambda u: any(u.has_perm(perm) for perm in args)) and when I try to run mypy I get:
|
Starting with #1038
user_passes_test
is typed to acceptAbstractBaseUser | AnonymousUser
. While technically correct it would be great if themypy
plugin could update this to be the actual model defined in settings. For example we have code like this that now complains:The text was updated successfully, but these errors were encountered: