Skip to content

User.objects is UserManager[Self]#177

Open
bobthemighty wants to merge 3 commits intosbdchd:mainfrom
carbon-re:fix/user-manager-specialises-to-self
Open

User.objects is UserManager[Self]#177
bobthemighty wants to merge 3 commits intosbdchd:mainfrom
carbon-re:fix/user-manager-specialises-to-self

Conversation

@bobthemighty
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

sbdchd commented Jul 9, 2023

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

@hamdanal
Copy link
Copy Markdown

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