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 eeb5175
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 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
except ImportError:
print("Failed to import torch.")

Expand Down

0 comments on commit eeb5175

Please sign in to comment.