From b2038f17ccc7dcd6e69ed15063711d8b4f9eee35 Mon Sep 17 00:00:00 2001 From: c-bata Date: Tue, 27 Oct 2020 03:01:40 +0900 Subject: [PATCH] Add mypy checks --- .github/workflows/python-tests.yml | 1 + DEVELOPMENT.md | 13 +++++++------ setup.py | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index faeed100..1f7e3331 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -22,6 +22,7 @@ jobs: pip install --progress-bar off .[lint] - run: flake8 . --show-source - run: black --check . + - run: mypy . test: runs-on: ubuntu-latest steps: diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 634a7abf..6fca9204 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,6 +1,6 @@ # Developers Guide -## Building source and running dashboard +## Building source and running dashboard server ### Building TypeScript files @@ -39,9 +39,9 @@ $ optuna-dashboard sqlite:///db.sqlite3 ## Submitting patches -Before you submitting patches, I recommend you to run tests, linters and auto-formatters. +To approve your patch, you need to pass following tests, lint checks. -### Running Python tests +### Running Python unit tests ``` $ python setup.py test @@ -52,11 +52,13 @@ Ran 4 tests in 0.004s OK ``` -### Linters +### Linters (flake8, black and mypy) ``` +$ pip install .[lint] $ flake8 $ black --check . +$ mypy . ``` ### Auto-formatting TypeScript files (by prettier) @@ -68,7 +70,6 @@ $ npm run fmt ### Auto-formatting Python files (by black) ``` -$ pip install .[lint] $ black . ``` @@ -78,7 +79,7 @@ $ black . The release process is fully automated by GitHub Actions. GitHub Actions will be automatically building TypeScript, packaging Python distributions and uploading to PyPI after you push the git tag. -1. Replace 'optuna_dashboard.version.__version__' to the next version. +1. Replace `optuna_dashboard.version.__version__` to the next version. 2. Create a git tag (e.g. `$ git tag v0.X.Y`). 3. Push the tag to GitHub (e.g. `$ git push origin v0.X.Y`) diff --git a/setup.py b/setup.py index cd795822..ad83d493 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,13 @@ from importlib.machinery import SourceFileLoader BASE_PATH = os.path.dirname(__file__) -def get_long_description(): +def get_long_description() -> str: readme_filepath = os.path.join(BASE_PATH, "README.md") with open(readme_filepath) as f: return f.read() -def get_version(): +def get_version() -> int: version_filepath = os.path.join(BASE_PATH, "optuna_dashboard", "version.py") module_name = "version" target_module = types.ModuleType(module_name) @@ -34,7 +34,7 @@ setup( packages=find_packages(), install_requires=["optuna", "bottle"], extras_require={ - "lint": ["black", "flake8"], + "lint": ["black", "flake8", "mypy"], "release": ["wheel", "twine"], }, package_data={"optuna_dashboard": ["public/*"]},