overridden-final-method / W0239ΒΆ

Message emitted:

Method %r overrides a method decorated with typing.final which is defined in class %r

Description:

Used when a method decorated with typing.final has been overridden.

Problematic code:

from typing import final


class Animal:
    @final
    def can_breathe(self):
        return True


class Cat(Animal):
    def can_breathe(self):  # [overridden-final-method]
        pass

Correct code:

from typing import final


class Animal:
    @final
    def can_breathe(self):
        return True


class Cat(Animal):
    def can_purr(self):
        return True

Configuration file:

[MAIN]
py-version=3.8

Additional details:

The message can't be emitted when using Python < 3.8.

Related links:

Created by the classes checker.