Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable pylint's unsubscriptable-object check #54

Closed
llucax opened this issue Jun 14, 2023 · 1 comment
Closed

Disable pylint's unsubscriptable-object check #54

llucax opened this issue Jun 14, 2023 · 1 comment
Assignees
Labels
part:cookiecutter Affects the generation of projects using cookiecutter part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) type:enhancement New feature or enhancement visitble to users
Milestone

Comments

@llucax
Copy link
Contributor

llucax commented Jun 14, 2023

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:

@llucax llucax added part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) type:enhancement New feature or enhancement visitble to users part:cookiecutter Affects the generation of projects using cookiecutter labels Jun 14, 2023
@llucax llucax added this to the v0.4.0 milestone Jun 14, 2023
@llucax
Copy link
Contributor Author

llucax commented Jul 8, 2023

Done in #81.

@llucax llucax closed this as completed Jul 8, 2023
@llucax llucax self-assigned this Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:cookiecutter Affects the generation of projects using cookiecutter part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) type:enhancement New feature or enhancement visitble to users
Projects
None yet
Development

No branches or pull requests

1 participant