subclassed-final-class / W0240ΒΆ
Message emitted:
Class %r is a subclass of a class decorated with typing.final: %r
Description:
Used when a class decorated with typing.final has been subclassed.
Problematic code:
from typing import final
@final
class PlatypusData:
"""General Platypus data."""
average_length = 46
average_body_temperature = 32
class FluorescentPlaytipus(PlatypusData): # [subclassed-final-class]
"""Playtipus with fluorescent fur."""
Correct code:
from typing import final
@final
class PlatypusData:
"""General Platypus data."""
average_length = 46
average_body_temperature = 32
def print_average_length_platypus():
output = f"The average length of a platypus is: {PlatypusData.average_length}cm"
print(output)
Configuration file:
[MAIN]
py-version=3.8
Additional details:
This message is emitted when a class which is decorated with final is subclassed; the decorator indicates that the class is not intended to be extended.
Note this message can't be emitted when using Python < 3.8.
Related links:
Created by the classes checker.