Skip to content

Commit

Permalink
Add mypy.ini (#357)
Browse files Browse the repository at this point in the history
* Add mypy.ini

* add `numpy.typing.mypy_plugin` to mypy.ini

* update type_check.yaml (#358)

* Update mypy.ini

Co-authored-by: Yoshiaki Bando <[email protected]>

* fix type_check.yaml

* Improve configs for readability

* modify test structures

* format .pre-commit-config.yaml

* rename test files

* Fix workflows

* fix workflows

* update tests

* Update workflows

---------

Co-authored-by: Yoshiaki Bando <[email protected]>
  • Loading branch information
aramoto99 and yoshipon authored Apr 7, 2024
1 parent e6d57d5 commit 45b3e81
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 203 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/actions.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI
on:
- push
- pull_request

jobs:
ci:
name: CI
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-22.04']
python-version: ['3.10']
test_target: ['apps', 'hpo']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .[dev,github-actions]
- name: Run pytest
run: pytest -v --cov=aiaccel --cov-branch --cov-report=term-missing tests/${{ strategy.target }}

27 changes: 0 additions & 27 deletions .github/workflows/code_formatter.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint
on:
- push
- pull_request

jobs:
lint:
name: Lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-22.04']
python-version: ['3.10']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .[dev,github-actions]
- name: Perform ruff
run: |
ruff check
ruff format --check
- name: Perform mypy
run: |
mypy --config-file mypy.ini .
31 changes: 0 additions & 31 deletions .github/workflows/sampler_algorithm_test.yaml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/type_check.yaml

This file was deleted.

49 changes: 21 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
hooks:
- id: mypy
args: [
"--install-types",
"--non-interactive",
"--ignore-missing-imports",
"--warn-unused-configs",
"--disallow-any-generics",
"--disallow-untyped-calls",
"--disallow-untyped-defs",
"--disallow-incomplete-defs",
"--check-untyped-defs",
"--disallow-untyped-decorators",
"--warn-redundant-casts",
"--warn-unused-ignores",
"--no-implicit-reexport",
"--strict-equality",
"--strict-concatenate",
]
exclude: ^(?:examples|tests)/.*
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
language: system
args: [--config-file, mypy.ini]
- repo: local
hooks:
- id: pytest
name: pytest
entry: pytest -s -v tests/
stages: [push]
language: system
pass_filenames: false
always_run: true
22 changes: 22 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[mypy]
python_version = 3.10
cache_dir = .mypy_cache

plugins = numpy.typing.mypy_plugin

allow_redefinition = True
warn_unused_configs = True
warn_redundant_casts = True
show_error_codes = True
show_column_numbers = True
check_untyped_defs = True
follow_imports = skip
local_partial_types = True
enable_error_code = possibly-undefined
warn_unused_ignores = False

strict_optional = True
warn_no_return = True
disallow_any_unimported = True
strict = True
implicit_reexport = False
40 changes: 10 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "aiaccel"
version = "2.0.0"
description = "A library for accelerating research on AI Bridging Cloud Infrastructure (ABCI)."
readme = "README.md"
requires-python = ">=3.8.1,<3.12"
requires-python = ">=3.10"
license = {text = "MIT"}
authors = [
{name = "AIST", email = "[email protected]"}
Expand All @@ -27,51 +27,31 @@ documentation = "https://aiaccel.readthedocs.io"
repository = "https://github.com/aistairc/aiaccel"

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"pytest-subprocess",
"undecorated",
]
github-actions = [
"pytest-github-actions-annotate-failures",
]
dev = [
"ruff",
"mypy",
"myst-parser",
"pre-commit",
"pytest",
"pytest-cov",
"pytest-subprocess",
"ruff",
"sphinx",
"sphinxcontrib-jquery",
"sphinx-intl",
"sphinx-fontawesome",
"sphinx-rtd-theme",
"undecorated",
]
github-actions = [
"pytest-github-actions-annotate-failures",
]

[tool.ruff]
line-length = 120
target-version = "py38"
target-version = "py310"
fix = true

select = ["E", "F", "W", "UP", "B", "SIM", "I", "C"]

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]

[tool.mypy]
python_version="3.8"
install_types = true
non_interactive = true
ignore_missing_imports = true
warn_unused_configs = true
disallow_any_generics = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
warn_redundant_casts = true
warn_unused_ignores = true
no_implicit_reexport = true
strict_equality = true
strict_concatenate = true
6 changes: 6 additions & 0 deletions tests/apps/test_hpo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from unittest import TestCase


class TestHpo(TestCase): # TODO: implement your test here
def test_hpo(self) -> None:
assert True
6 changes: 6 additions & 0 deletions tests/hpo/samplers/test_nelder_mead_sampler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from unittest import TestCase


class TestNelderMeadSampler(TestCase):
def test_nelder_mead(self) -> None:
assert True # TODO: implement your test here
6 changes: 0 additions & 6 deletions tests/sampler/nelder_mead/test_nelder_mead.py

This file was deleted.

6 changes: 0 additions & 6 deletions tests/unit_tests/test_aiaccel.py

This file was deleted.

0 comments on commit 45b3e81

Please sign in to comment.