Skip to content

Disable pylint's unsubscriptable-object check #54

Description

@llucax

pylint's unsubscriptable check is unreliable, having some false positives. For example:

"""Test pylint."""


class AClass:
    """Test pylint."""

    a_map: dict[str, int] | None = None

    def __str__(self) -> str:
        """Test pylint."""
        return "None" if not self.a_map else self.a_map["a"]


class BClass(AClass):
    """Test pylint."""

    a_map = {"a": 1}

This produces an error E1136: Value 'a_map' is unsubscriptable (unsubscriptable-object) when using self.a_map["a"], which is wrong.

This check is also redundant, as it is a type check, which is already done (better) by mypy.

We should add this to the cookiecutter pyproject.toml template:

[tool.pylint.messages_control]
disable = [
    # ...
    "unsubscriptable-object",
]

The SDK is already using this ignore:

Metadata

Metadata

Assignees

Labels

part:cookiecutterAffects the generation of projects using cookiecutterpart:toolingAffects the development tooling (CI, deployment, dependency management, etc.)type:enhancementNew feature or enhancement visitble to users

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions