Flagsmith / Flagsmith/flagsmith
Spike: Improve user types
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 567
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 121
Description
Investigate the effort to improve typing around our user models, with the ultimate goal of improving existing inconsistencies.
As of now we have:
- `FFAdminUser` ([ref](https://github.com/Flagsmith/flagsmith/blob/18f3f09027b7acdb99751342881152ad53feb5b2/api/users/models.py#L108)): implements Django's AbstractUser.
- `APIKeyUser` ([ref](https://github.com/Flagsmith/flagsmith/blob/f7487ac5278d60e62067e2f4d5976ceb755f4980/api/api_keys/user.py#L22)): implements `UserABC`.
- `UserABC` ([ref](https://github.com/Flagsmith/flagsmith/blob/f7487ac5278d60e62067e2f4d5976ceb755f4980/api/users/abc.py#L10)): why does it exist?
Maybe get rid of `UserABC`, or if otherwise proven necessary, make it our go-to base user class instead of relying on a [subclass hook](https://github.com/Flagsmith/flagsmith/blob/f7487ac5278d60e62067e2f4d5976ceb755f4980/api/users/abc.py#L66-L68).
An example of issue this causes is: likely because of `settings.DJANGO_USER_MODEL`, DRF will type `request.user` as `FFAdminUser | AnonymousUser`, which is incompatible with the actual `APIKeyUser` type and misleading.
This will also probably fix https://github.com/flagsmith/flagsmith/issues/4379.
Contributor guide
Assessment
This issue has not been assessed yet.