Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stricter mypy type check flags #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
script:
- pytest --cov=dacite
- black --check .
- mypy dacite
- mypy
- pylint dacite
after_success:
coveralls
Expand Down
22 changes: 21 additions & 1 deletion dacite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
from dacite.config import Config
from dacite.core import from_dict
from dacite.exceptions import *
from dacite.exceptions import (
DaciteError,
DaciteFieldError,
WrongTypeError,
MissingValueError,
UnionMatchError,
ForwardReferenceError,
UnexpectedDataError,
)

__all__ = (
"Config",
"from_dict",
"DaciteError",
"DaciteFieldError",
"WrongTypeError",
"MissingValueError",
"UnionMatchError",
"ForwardReferenceError",
"UnexpectedDataError",
)
2 changes: 1 addition & 1 deletion dacite/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_default_value_for_field(field: Field) -> Any:


def create_instance(data_class: Type[T], init_values: Data, post_init_values: Data) -> T:
instance = data_class(**init_values)
instance: T = data_class(**init_values)
for key, value in post_init_values.items():
setattr(instance, key, value)
return instance
2 changes: 1 addition & 1 deletion dacite/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def is_generic_collection(type_: Type) -> bool:


def extract_generic(type_: Type) -> tuple:
return type_.__args__ # type: ignore
return type_.__args__


def is_subclass(sub_type: Type, base_type: Type) -> bool:
Expand Down
22 changes: 22 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[mypy]
python_version = 3.6
files = dacite
show_error_codes = True
pretty = True

no_implicit_reexport = True
no_implicit_optional = True
strict_equality = True
strict_optional = True
check_untyped_defs = True
disallow_incomplete_defs = True
ignore_missing_imports = False

warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
warn_unreachable = True

[mypy-dacite.types]
warn_return_any = False