Skip to content

Commit

Permalink
Merge pull request #129 from narumiruna/refactor
Browse files Browse the repository at this point in the history
REFACTOR: update type hints to use union syntax for optional parameters
  • Loading branch information
narumiruna authored Nov 9, 2024
2 parents 4e71d34 + dabaea0 commit 8d86536
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mlconfig/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import copy
import functools
from typing import Any
from typing import Optional
from typing import Union

from omegaconf import DictConfig
from omegaconf import ListConfig
Expand All @@ -12,7 +12,7 @@
_key = "name"


def load(f: Optional[str] = None, obj: Optional[Any] = None) -> Union[ListConfig, DictConfig]:
def load(f: str | None = None, obj: Any | None = None) -> 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 @@ -41,7 +41,7 @@ def load(f: Optional[str] = None, obj: Optional[Any] = None) -> Union[ListConfig
return OmegaConf.merge(*configs)


def register(func_or_cls=None, name: Optional[str] = None):
def register(func_or_cls=None, name: str | None = None):
r"""Register function or class
Args:
Expand Down Expand Up @@ -84,7 +84,7 @@ def instantiate(conf, *args, **kwargs):
return func_or_cls(*args, **kwargs)


def flatten(data: dict, prefix: Optional[str] = None, sep: str = ".") -> dict:
def flatten(data: dict, prefix: str | None = None, sep: str = ".") -> dict:
d = {}

for key, value in data.items():
Expand Down

0 comments on commit 8d86536

Please sign in to comment.