Skip to content

Add stricter mypy type check flags#76

Open
antonagestam wants to merge 2 commits intokonradhalas:masterfrom
antonagestam:feature/strict-type-checks
Open

Add stricter mypy type check flags#76
antonagestam wants to merge 2 commits intokonradhalas:masterfrom
antonagestam:feature/strict-type-checks

Conversation

@antonagestam
Copy link
Contributor

  • Remove unused type: ignore.
  • Remove asterisk import and add __all__ with all exported names, to
    pass with the no_explicit_reexport mypy flag.
  • Add various mypy config for developer ergonomics (prettier errors,
    printing error codes, warning about unused config, ignores and casts
    etc). Kept warn_return_any = False in dacite.types for now since there
    would have to be a lot of ignores/casts otherwise.

This is a somewhat opinionated PR. The added __all__ makes the public API of the package more explicit and enables consumers of the library to type check with no_explicit_reexport = True in mypy. Adding python_version = 3.6 helps finding incompatibilities, such as trying to import Literal from stdlib typing, with mypy. dacite already passes with most of the stricter settings except for one found unnecessary ignore (warn_unused_ignores) and one added type hint in dacite.dataclasses.create_instance(). The exception is the dacite.types module where mypy isn't very successful at inferring return types, so I set warn_return_any = False for that file.

As I said I consider this opinionated, but do feel free to ask for changes if you're interested in some or all of these changes.

- Remove unused type: ignore.
- Remove asterisk import and add `__all__` with all exported names, to
  pass with the `no_explicit_reexport` mypy flag.
- Add various mypy config for developer ergonomics (prettier errors,
  printing error codes, warning about unused config, ignores and casts
  etc). Kept `warn_return_any = False` in `dacite.types` for now since there
  would have to be a lot of ignores/casts otherwise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant