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

User.objects is UserManager[Self] #177

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bobthemighty
Copy link

This commit fixes an issue with extending the User class.

Previously, MySpecialUser.objects would return a UserManager[User]. This commit updates the objects field to parameterise over Self, so that MySpecialUser.objects returns a UserManager[MySpecialUser].

This commit fixes the issue where you extend the User class.
Previously, MySpecialUser.objects would return a UserManager[User]. This
commit updates the objects field to paramterise over Self, so that
MySpecialUser.objects returns a UserManager[MySpecialUser].
@sbdchd
Copy link
Owner

sbdchd commented Jul 8, 2023

Looks good!

Linter is a little angry:

18
All done! ✨ 🍰 ✨
[19](https://github.com/sbdchd/django-types/actions/runs/5488440137/jobs/10001296563?pr=177#step:8:20)
3 files reformatted, 699 files left unchanged.
[20](https://github.com/sbdchd/django-types/actions/runs/5488440137/jobs/10001296563?pr=177#step:8:21)
+ ./.venv/bin/isort tests typings
[21](https://github.com/sbdchd/django-types/actions/runs/5488440137/jobs/10001296563?pr=177#step:8:22)
+ ./.venv/bin/mypy tests typings
[22](https://github.com/sbdchd/django-types/actions/runs/5488440137/jobs/10001296563?pr=177#step:8:23)
tests/trout/models.py:1050:1: error: Access to generic instance variables via class is ambiguous  [misc]
[23](https://github.com/sbdchd/django-types/actions/runs/5488440137/jobs/10001296563?pr=177#step:8:24)
Found 1 error in 1 file (checked 702 source files)
[24](https://github.com/sbdchd/django-types/actions/runs/5488440137/jobs/10001296563?pr=177#step:8:25)
Error: Process completed with exit code 1.

@bobthemighty
Copy link
Author

Locally ./s/lint now runs clean, so I'm unsure how to reproduce the build failure I have here. Any clue?

@sbdchd
Copy link
Owner

sbdchd commented Jul 9, 2023

Hmm seems mypy is mad, maybe # type: ignore[misc] for now?

@hamdanal
Copy link

It appears that #181 fixes User.objects type annotation. @bobthemighty would you like to change the PR to only include the test? Otherwise this PR can be closed.

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.

3 participants