From cb1d3dd68e8133a8dc942c5ccaad62b8d9505910 Mon Sep 17 00:00:00 2001 From: 0x000011b <0x000011b@waifu.club> Date: Sat, 17 Dec 2022 21:31:41 -0300 Subject: [PATCH] chore: enable strict mode on mypy, add isort check --- .gitignore | 1 + pyproject.toml | 3 ++- waifu/datasets/__init__.py | 2 +- waifu/modules/__init__.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e79fdf9..ff56f64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /*.egg-info/ **/__pycache__/ +/.mypy_cache/ /.pdm.toml /.venv/ diff --git a/pyproject.toml b/pyproject.toml index e68e205..73510c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,8 +28,9 @@ py-modules = ["waifu"] [tool.pdm.scripts] lint = {shell = "pylint --jobs 0 ./waifu/**/*.py"} +importcheck = "isort --check --diff waifu" stylecheck = "yapf --parallel --diff --recursive waifu" -typecheck = "mypy waifu" +typecheck = "mypy --strict waifu" [tool.yapf] based_on_style = "google" diff --git a/waifu/datasets/__init__.py b/waifu/datasets/__init__.py index a49b65a..c54d2d9 100644 --- a/waifu/datasets/__init__.py +++ b/waifu/datasets/__init__.py @@ -6,7 +6,7 @@ T = t.TypeVar("T") class BaseDataset(t.Generic[T]): '''Base dataset class.''' - def __iter__(self): + def __iter__(self) -> t.Generator[T, None, None]: '''Implements the basic iterator interface.''' return self.generator() diff --git a/waifu/modules/__init__.py b/waifu/modules/__init__.py index c860e29..540c4a1 100644 --- a/waifu/modules/__init__.py +++ b/waifu/modules/__init__.py @@ -4,7 +4,7 @@ import typing as t class BaseModule: '''Base module class.''' - def __iter__(self): + def __iter__(self) -> t.Generator[str, None, None]: '''Implements the basic iterator interface.''' return self.generator()