PY3.W0240

Subclassed final class

Used when a class decorated with typing.final has been subclassed.

Noncompliant Code:

Copy
from typing import final

@final
class PlatypusData:
    """General Platypus data."""

    average_length = 46
    average_body_temperature = 32

class FluorescentPlaytipus(PlatypusData):
    """Playtipus with fluorescent fur."""

Compliant Code:

Copy
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)

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.

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.