Skip to content

Instantly share code, notes, and snippets.

@ftnext
Last active February 17, 2026 23:52
Show Gist options
  • Select an option

  • Save ftnext/ce0432a9d639dde032db3dc4e0113302 to your computer and use it in GitHub Desktop.

Select an option

Save ftnext/ce0432a9d639dde032db3dc4e0113302 to your computer and use it in GitHub Desktop.
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