Skip to content

Stricter type hint linting #332

@l0b0

Description

@l0b0

Would you be interested in stricter type hint linting? I've implemented these additional mypy settings in another project already:

  • check_untyped_defs "Type-checks the interior of functions without type annotations."
  • disallow_any_generics "Disallows usage of generic types that do not specify explicit type parameters."
  • no_implicit_optional "Changes the treatment of arguments with a default value of None by not implicitly making their type Optional." Basically, declaring a parameter foo: str = None becomes an error, rather than being implicitly treated as Optional[str].
  • show_error_codes "Shows error codes in error messages." This makes it easier to write type: ignore[SPECIFIER] comments (which are more specific than the big hammer, type: ignore), since the SPECIFIER part of that is part of the error message.
  • warn_redundant_casts "Warns about casting an expression to its inferred type."
  • warn_return_any "Shows a warning when returning a value with type Any from a function declared with a non-Any return type."
  • warn_unused_ignores "Warns about unneeded # type: ignore comments."

I've also avoided ignore_missing_imports simply by marking only a handful of specific imports as ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions