Skip to content

Overridden method missing type annotations inspection

Report overriding methods that dropped type annotations from the parent method. The quick-fix copies the missing annotations from the parent so subclass signatures stay readable and type-checker friendly.

How to invoke

Enable the inspection, place the caret on a highlighted override, then use ⌥⏎ / Alt+Enter -> "Copy type annotations from parent".

Example

class Repository:
    def save(self, item: Order) -> None:
        ...


class SqlRepository(Repository):
    def save(self, item):
        ...

becomes:

class SqlRepository(Repository):
    def save(self, item: Order) -> None:
        ...

What it supports

  • Overrides that inherit parameter and return annotations from a parent method.
  • Partial fixes when only some annotations are missing.
  • Import insertion when copied annotations need names from another module.
  • Alias-aware imports in common cases.

What it deliberately avoids

  • Methods that do not override a typed parent method.
  • Overrides where the parent and child signatures are incompatible.
  • Applying a fix when copied names would introduce unresolved or conflicting references without user confirmation.
  • Library and stub files outside your project.

Notes

  • This inspection is the diagnostic companion to the Copy method annotations from parent intention.
  • The feature is gated by the Overridden method missing type annotations inspection setting under Settings | BetterPy | Typing & Type Hints | Code Inspections.