Skip to content

False positive: unsubscriptable-object when using classmethod and property together #5699

Open

Description

Bug description

from typing import List


class Unknown:

    CONSTANT_1 = 0
    CONSTANT_2 = 1
    CONSTANT_3 = 2

    @classmethod
    @property
    def all_constants(cls) -> List[int]:
        return [cls.CONSTANT_1, cls.CONSTANT_2, cls.CONSTANT_3]


print(Unknown.all_constants[0])  # false positive unsubscriptable-object

... 0

>>> Unknown.all_constants
... [0, 1, 2]

Configuration

No response

Command used

pylint untitled.py and VSCode linter

Pylint output

************* Module untitled
untitled.py:16:6: E1136: Value 'Unknown.all_constants' is unsubscriptable (unsubscriptable-object)

-------------------------------------------------------------------
Your code has been rated at -1.25/10

Expected behavior

************* Module untitled


Your code has been rated at 10/10

Pylint version

pylint 2.12.2
astroid 2.9.2
Python 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:36:06) [MSC v.1929 64 bit (AMD64)]

OS / Environment

Edição Windows 11 Pro
Versão 21H2
Instalado em ‎10/‎10/‎2021
Compilação do SO 22000.434
Experiência Pacote de Experiência de Recursos do Windows 1000.22000.434.0

Additional dependencies

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C: unsubscriptable-objectIssues related to 'unsubscriptable-object' checkDecoratorsFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions