Skip to content

Comments

Remove redundant subclass method annotations#917

Open
brianhelba wants to merge 2 commits intotypeddjango:masterfrom
brianhelba:redundant-subclass
Open

Remove redundant subclass method annotations#917
brianhelba wants to merge 2 commits intotypeddjango:masterfrom
brianhelba:redundant-subclass

Conversation

@brianhelba
Copy link
Contributor

These methods will be inherited from the parent class unchanged.

These methods will be inherited from the parent class
unchanged.
@brianhelba
Copy link
Contributor Author

@intgr PTAL.

@intgr intgr requested review from Copilot and intgr and removed request for intgr February 23, 2026 13:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request removes redundant method type annotations from subclasses in Django REST Framework stubs. When a subclass doesn't override a method's implementation, the type annotation is automatically inherited from the parent class, making explicit re-declaration unnecessary. Additionally, the PR improves type specificity in BasePagination.get_schema_fields by changing its return type from list[Any] to list[CoreAPIField].

Changes:

  • Removed redundant __new__ and __class_getitem__ annotations from BaseSerializer that are inherited from Field
  • Removed unused typing_extensions.Self import from serializers.pyi
  • Improved type specificity of BasePagination.get_schema_fields return type from list[Any] to list[CoreAPIField]
  • Removed redundant paginate_queryset, get_paginated_response_schema, and get_schema_fields method annotations from pagination subclasses

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rest_framework-stubs/serializers.pyi Removed redundant __new__ and __class_getitem__ methods from BaseSerializer and the now-unused Self import
rest_framework-stubs/pagination.pyi Improved BasePagination.get_schema_fields return type specificity and removed redundant method annotations from PageNumberPagination, LimitOffsetPagination, and CursorPagination subclasses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant