Last active
February 17, 2026 23:52
-
-
Save ftnext/ce0432a9d639dde032db3dc4e0113302 to your computer and use it in GitHub Desktop.
ref: https://nikkie-ftnext.hatenablog.com/entry/flake8-kotoha-experiment-pylint-checker-implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from astroid import nodes | |
| from pylint.checkers import BaseChecker | |
| class ArgumentListTypeHintChecker(BaseChecker): | |
| name = "kotoha-checker" | |
| priority = -1 | |
| msgs = { | |
| "W9999": ( | |
| "Avoid concrete list type in argument '%s'; use Sequence or Iterable instead", | |
| "avoid-list-arg-type", | |
| "Concrete list type in function argument type hints should be avoided.", | |
| ), | |
| } | |
| def visit_arguments(self, node: nodes.Arguments) -> None: | |
| for annotation in node.annotations: | |
| if ( | |
| isinstance(annotation, nodes.Subscript) | |
| and isinstance(annotation.value, nodes.Name) | |
| and annotation.value.name == "list" | |
| ): | |
| self.add_message( | |
| "avoid-list-arg-type", | |
| node=annotation, | |
| args=(annotation.value.name,), | |
| ) | |
| def register(linter): | |
| linter.register_checker(ArgumentListTypeHintChecker(linter)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment