Skip to content

Prevent overriding of Final attributes in subclasses #871

@sharkdp

Description

@sharkdp

Attributes which are qualified as Final may not be overwritten in subclasses (spec):

from typing import Final

class Base:
    CONSTANT: Final[int] = 1

class Derived(Base):
    CONSTANT = 2  # This should be an error

We have an existing test (with TODOs) for this here.

I imagine that it might be convenient to implement this once we have #166 (because that would require similar mechanisms to look up equivalent attributes in base classes), but it might also make sense to implement this independently.

Metadata

Metadata

Assignees

Labels

typing semanticstyping-module features, spec compliance, etc

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions