[Python] Expected type ..., got 'property' instead

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I have a class which have method wrapped by two decorators @classmethod and @property.

    class Foo:
    @classmethod
    @property
    def status(cls) -> bool:
    return True

    def print_status(status: bool) -> None:
    print(f'{Foo.status=}')

    print_status(Foo.status) # Foo.status=True


    But it PyCharm i see warning Expected type 'bool', got 'property' instead :

    [​IMG]

    It works as expected, just want to understand why this warning appears even with annotated functions?

    > PyCharm 2023.1.2 (Community Edition) Build #PC-231.9011.38, built on
    > May 17, 2023 Runtime version: 17.0.6+10-b829.9 amd64 VM: OpenJDK
    > 64-Bit Server VM by JetBrains s.r.o. Linux 5.19.0-43-generic GC: G1
    > Young Generation, G1 Old Generation Memory: 1994M Cores: 12 Registry:
    > undo.documentUndoLimit=1000
    > ide.smart.update=true
    > debugger.new.tool.window.layout=true
    > ide.experimental.ui=true
    >
    > Non-Bundled Plugins:
    > com.intellij.ideolog (203.0.30.0)
    > net.sjrx.intellij.plugins.systemdunitfiles (223.230322.126)
    > IdeaVIM (2.3.0)
    > net.seesharpsoft.intellij.plugins.csv (3.2.0-231)
    > nl.jusx.pycharm.lineprofiler (1.7.0)
    > net.ashald.envfile (3.4.1)
    > com.koxudaxi.pydantic (0.4.2-231)
    >
    > Current Desktop: KDE

    Continue reading...

Compartilhe esta Página