Add stricter mypy type check flags#76
Open
antonagestam wants to merge 2 commits intokonradhalas:masterfrom
Open
Add stricter mypy type check flags#76antonagestam wants to merge 2 commits intokonradhalas:masterfrom
antonagestam wants to merge 2 commits intokonradhalas:masterfrom
Conversation
- 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 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
__all__with all exported names, topass with the
no_explicit_reexportmypy flag.printing error codes, warning about unused config, ignores and casts
etc). Kept
warn_return_any = Falseindacite.typesfor now since therewould 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 withno_explicit_reexport = Truein mypy. Addingpython_version = 3.6helps finding incompatibilities, such as trying to importLiteralfrom stdlibtyping, 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 indacite.dataclasses.create_instance(). The exception is thedacite.typesmodule where mypy isn't very successful at inferring return types, so I setwarn_return_any = Falsefor 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.