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

Item "AbstractBaseUser" of "Union[AbstractBaseUser, AnonymousUser]" has no attribute "is_superuser" #1282

Closed
Archmonger opened this issue Dec 6, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@Archmonger
Copy link

Bug report

What's wrong

AbstractBaseUser does not appear to be properly type hinted

# This causes the following MyPy error...
# Item "AbstractBaseUser" of "Union[AbstractBaseUser, AnonymousUser]" has no attribute "is_superuser"
@method_decorator(user_passes_test(lambda u: u.is_superuser), name="dispatch")
class GeneralSettingsView(UpdateView):
    ...

How is that should be

All expected attributes off AbstractBaseUser should be exposed to MyPy

System information

  • OS:
  • python version: 3.10
  • django version: 4.1
  • mypy version: 0.982
  • django-stubs version: 1.13
  • django-stubs-ext version: 0.7.0
@Archmonger Archmonger added the bug Something isn't working label Dec 6, 2022
@sobolevn
Copy link
Member

sobolevn commented Dec 6, 2022

pr is welcome!

@Archmonger
Copy link
Author

Some additional digging tells me that is_superuser is not a valid field of AbstractBaseUser. So the issue I'm experiencing appears to be #1058.

However, I did notice that the clean field is currently not defined within the AbstractBaseUser type hints.

Is it worth PRing this if the definition is only def clean(self) -> None: ...?

Technically unneeded, but depends on if this repo prioritizes completeness or not.

@Archmonger
Copy link
Author

Closing in favor of #1058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants