Skip to content

Repair the type annotations in the TokenViewBase class.#880

Merged
vgrozdanic merged 4 commits intojazzband:masterfrom
triplepoint:token_type_fix
Mar 3, 2025
Merged

Repair the type annotations in the TokenViewBase class.#880
vgrozdanic merged 4 commits intojazzband:masterfrom
triplepoint:token_type_fix

Conversation

@triplepoint
Copy link
Contributor

@triplepoint triplepoint commented Mar 2, 2025

When extending the TokenViewBase class in order to override the serializer_class property, the type of the property is already established as NoneType, causing type check errors.

This PR explicitly annotates serializer_class to be Optional[Type[Serializer]], allowing for the default None and also any other class that is a child of Serializer.

Note also that the type of the return of get_serializer_class() was erroneously Serializer (an instance of Serializer), when it should be Type[Serializer] (a class who's type includes Serializer).

EDIT: Turned out BaseSerializer was the correct type, not Serializer.

@triplepoint triplepoint requested a review from vgrozdanic March 2, 2025 22:26
Copy link
Contributor

@vgrozdanic vgrozdanic left a comment

Choose a reason for hiding this comment

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

Nice, thank you

@vgrozdanic vgrozdanic merged commit 00de028 into jazzband:master Mar 3, 2025
23 checks passed
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.

2 participants