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

AbstractBaseSession: Use model fields for subclassed cases #2180

Merged
merged 3 commits into from
May 25, 2024

Conversation

tony
Copy link
Contributor

@tony tony commented May 24, 2024

Changes

AbstractBaseSession fields

These currently raise on mypy when overridden, such as by overriding max_length, see example in #2179.

In situations where these fields are overridden in custom models, for instance extending 'session_key's max_length. Follow a similar style to AbstractBaseUser` (django: 5.0.6, django-stubs: 5.0.0).

See also:

Related issues

@tony tony force-pushed the django-abstract-base-session-fields branch from 43caa11 to a085728 Compare May 24, 2024 10:45
@tony tony force-pushed the django-abstract-base-session-fields branch 2 times, most recently from a2c020b to ead98c8 Compare May 24, 2024 15:07
@flaeppe flaeppe self-assigned this May 24, 2024
@tony
Copy link
Contributor Author

tony commented May 24, 2024

@intgr @flaeppe When applying suggested changes, do you prefer I keep your commits atomic, or just squash them into mine? (Up to you)

@tony tony force-pushed the django-abstract-base-session-fields branch from 3dcaf71 to 6cbe46c Compare May 24, 2024 15:29
@flaeppe
Copy link
Member

flaeppe commented May 24, 2024

@intgr @flaeppe When applying suggested changes, do you prefer I keep your commits atomic, or just squash them into mine? (Up to you)

I can't say that I have any preference. From my end you can do whatever you feel works best

@intgr
Copy link
Collaborator

intgr commented May 24, 2024

Yeah, do whatever is quickest. The commits will be squashed on merge anyway.

@tony tony force-pushed the django-abstract-base-session-fields branch 7 times, most recently from b44dcc4 to da0fad5 Compare May 24, 2024 16:53
@tony tony force-pushed the django-abstract-base-session-fields branch from da0fad5 to ae795ce Compare May 24, 2024 20:00
Copy link
Member

@flaeppe flaeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Thank you!

@tony
Copy link
Contributor Author

tony commented May 24, 2024

@flaeppe @intgr Vice versa! We made it!

@tony
Copy link
Contributor Author

tony commented May 24, 2024

We made it!

Maybe I spoke too soon. @intgr Is this solution fine with you?

@flaeppe
Copy link
Member

flaeppe commented May 25, 2024

I'll merge this in the meantime. Lets circle back if we figure out that there's anything more that needs to be done.

@flaeppe flaeppe merged commit 1f4efbe into typeddjango:master May 25, 2024
36 checks passed
session_key = models.CharField(primary_key=True)
session_data = models.TextField()
expire_date = models.DateTimeField()
objects: ClassVar[BaseSessionManager[Self]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this is better because it's more precise, thanks.

@tony tony deleted the django-abstract-base-session-fields branch May 27, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

AbstractBaseSession subclassing: Fields not overridable
3 participants