Skip to content

Commit

Permalink
type check
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed May 20, 2024
1 parent fe3c1a4 commit 5e7db9e
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
-
name: Lint
run: poetry run ruff check .
-
name: Type check
run: poetry run mypy mlconfig
-
name: Test
run: poetry run pytest -v -s --cov=mlconfig --cov-report=xml tests
Expand Down
8 changes: 6 additions & 2 deletions mlconfig/conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import copy
import functools
from typing import Any
from typing import Optional
from typing import Union

from omegaconf import DictConfig
from omegaconf import ListConfig
from omegaconf import OmegaConf

_registry = {}
_key = "name"


def load(f=None, obj=None) -> OmegaConf:
def load(f: Optional[str] = None, obj: Optional[Any] = None) -> Union[ListConfig, DictConfig]:
"""Load configuration file or structured object.
If both are provided, then the configuration from file
will override the configuration from structured object.
Expand Down Expand Up @@ -37,7 +41,7 @@ def load(f=None, obj=None) -> OmegaConf:
return OmegaConf.merge(*configs)


def register(func_or_cls=None, name: str = None):
def register(func_or_cls=None, name: Optional[str] = None):
r"""Register function or class
Args:
Expand Down
2 changes: 1 addition & 1 deletion mlconfig/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import mlconfig

try:
from torch import optim
from torch import optim # type: ignore

Check warning on line 6 in mlconfig/torch/__init__.py

View check run for this annotation

Codecov / codecov/patch

mlconfig/torch/__init__.py#L6

Added line #L6 was not covered by tests
except ImportError:
print("Failed to import torch.")

Expand Down
71 changes: 70 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pytest = "^7.4.3"
pytest-cov = "^4.1.0"
ruff = "^0.2.0"
toml = "^0.10.2"
mypy = "^1.10.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit 5e7db9e

Please sign in to comment.