Skip to content

Fix mistaken type annotation - #184

Open
mgax wants to merge 2 commits into
eadwinCode:masterfrom
mgax:fix/for-user-return-type-bis
Open

Fix mistaken type annotation#184
mgax wants to merge 2 commits into
eadwinCode:masterfrom
mgax:fix/for-user-return-type-bis

Conversation

@mgax

@mgax mgax commented Jul 27, 2026

Copy link
Copy Markdown

In #179 I added a broken type annotation:

    @classmethod
    def for_user(cls: T, user: AbstractBaseUser) -> T:

Since for_user is a classmethod, its first argument is a class, not an instance. The correct annotation would be:

    @classmethod
    def for_user(cls: Type[T], user: AbstractBaseUser) -> T:

I have checked both versions by running uv tool run --with=. ty check /tmp/typing-sandbox.py in the django-ninja-jwt worktree against this sample file:

# /tmp/typing-sandbox.py
from ninja_jwt.tokens import Token, RefreshToken
from django.contrib.auth.models import User

Token().for_user(User())
RefreshToken().for_user(User())

Apologies for the mistaken PR – I had tested the change locally but it seems I was not careful 🙈

I would be happy to add ty check to CI if that contribution would be accepted.

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.

1 participant