Skip to content

final overrides not detected on methods decorated with cache #10543

@eachimei

Description

@eachimei

In the below example we expect pyright to flag all 3 overrides as violations due to all methods decorated with @final in the base-class. However, only simple is flagged:

from functools import cache
from typing import final


class Parent:

    @final
    def simple(self):
        ...

    @final
    @cache
    def final_over_cache(self):
        ...

    @cache
    @final
    def cache_over_final(self):
        ...


class Child(Parent):

    def simple(self):
        ...

    @cache
    def final_over_cache(self):
        ...

    @cache
    def cache_over_final(self):
        ...

Output:

>pyright pyright_final.py
pyright_final.py
  pyright_final.py:24:9 - error: Method "simple" cannot override final method defined in class "Parent" (reportIncompatibleMethodOverride)
1 error, 0 warnings, 0 informations

Version information:
Python 3.10.11
pyright 1.1.401

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions