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:
pylint's unsubscriptable check is unreliable, having some false positives. For example:This produces an error
E1136: Value 'a_map' is unsubscriptable (unsubscriptable-object)when usingself.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.tomltemplate:The SDK is already using this ignore: