Skip to content

Commit

Permalink
Merge pull request #17 from soldni/soldni/rich2
Browse files Browse the repository at this point in the history
Removed rich logger during module import
  • Loading branch information
soldni authored Apr 3, 2023
2 parents 2ac6aff + 56ecf24 commit e52778e
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "springs"
version = "1.12.2"
version = "1.12.3"
description = """\
A set of utilities to create and manage typed configuration files \
effectively, built on top of OmegaConf.\
Expand Down
1 change: 0 additions & 1 deletion src/springs/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ def wrap_main_method(
*args: MP.args,
**kwargs: MP.kwargs,
) -> RT:

if not isinstance(config_node, DictConfig):
raise TypeError("Config node must be a DictConfig")

Expand Down
4 changes: 2 additions & 2 deletions src/springs/field_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def field(
*,
help: str | None = ...,
omegaconf_ignore: bool = ...,
**kwargs
**kwargs,
) -> _T: ...
@overload
def field(
default_factory: Callable[..., _T],
*,
help: str | None = ...,
omegaconf_ignore: bool = ...,
**kwargs
**kwargs,
) -> _T: ...

class HelpLookup:
Expand Down
1 change: 0 additions & 1 deletion src/springs/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class InitLater(functools.partial):

# inherits slots from functools.partial
__slots__ = ("type_",)

Expand Down
7 changes: 2 additions & 5 deletions src/springs/memoizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import inspect
import pickle
from functools import reduce, wraps
from logging import getLogger
from pathlib import Path
from typing import Callable, Optional, Tuple, TypeVar, Union

from platformdirs import user_cache_dir
from typing_extensions import ParamSpec

from .initialize import Target
from .logging import configure_logging

LOGGER = configure_logging(__file__)
LOGGER = getLogger(__name__)

P = ParamSpec("P")
R = TypeVar("R")
Expand Down Expand Up @@ -51,7 +51,6 @@ def memoize(
full_cache_dir.mkdir(parents=True, exist_ok=True)

def _memoize(func: Callable[P, R]) -> Callable[P, R]:

# get the fully specified function name
function_name = Target.to_string(func)

Expand All @@ -61,7 +60,6 @@ def _memoize(func: Callable[P, R]) -> Callable[P, R]:

@wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:

# we accumulate all arguments in a hash here; we also use the
# fully specified function name to derive a filename at which
# to cache.
Expand All @@ -76,7 +74,6 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
# we iterate over the arguments and add them to the hash unless
# the are either a class instance or a function.
for i, (k, v) in enumerate(bounded_arguments.arguments.items()):

if i == 0 and (k == "self" or k == "cls"):
# we skip cls or self if they are the first argument
# provided.
Expand Down
4 changes: 2 additions & 2 deletions src/springs/nicknames.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
from dataclasses import is_dataclass
from inspect import isclass
from logging import getLogger
from pathlib import Path
from typing import (
Callable,
Expand All @@ -22,7 +23,6 @@

from .core import from_dict, from_file, to_python
from .flexyclasses import FlexyClass
from .logging import configure_logging

RegistryValue = Union[Callable, Type[FlexyClass], DictConfig, ListConfig]
# M = TypeVar("M", bound=RegistryValue)
Expand All @@ -31,7 +31,7 @@
P = ParamSpec("P")


LOGGER = configure_logging(__name__)
LOGGER = getLogger(__name__)


class NicknameRegistry:
Expand Down
1 change: 0 additions & 1 deletion src/springs/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def register(
name: str, use_cache: bool = False
) -> Callable[[Callable[..., T]], Callable[..., T]]:
def _register(func: Callable[..., T]) -> Callable[..., T]:

# will raise an error if the resolver is already registered
OmegaConf.register_new_resolver(
name=name, resolver=func, use_cache=use_cache, replace=False
Expand Down
1 change: 0 additions & 1 deletion src/springs/rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def format_usage(self):

for ag in self._action_groups:
for act in ag._group_actions:

if isinstance(act.metavar, str):
metavar = (act.metavar,)
elif act.metavar is None:
Expand Down
1 change: 0 additions & 1 deletion src/springs/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def traverse(
include_root: bool = False,
recurse: bool = True,
) -> Iterator[ParamSpec]:

help = HelpLookup(node)

if include_root:
Expand Down
6 changes: 4 additions & 2 deletions src/springs/types_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def get_type_hint(obj: Any, key: Any = None) -> Optional[Type[Any]]:
def is_union_annotation(type_: Any) -> bool:
"""Check wether `type_` is equivalent to `typing.Union[T, ...]`
From https://github.com/omry/omegaconf/blob/e95c2c76d2545a844794682108ded57fbf98f042/omegaconf/_utils.py#L195""" # noqa: E501
From https://github.com/omry/omegaconf/blob/e95c2c76d2545a844794682108ded57fbf98f042/omegaconf/_utils.py#L195
""" # noqa: E501
if sys.version_info >= (3, 10):
if isinstance(type_, types.UnionType):
return True
Expand All @@ -47,7 +48,8 @@ def resolve_optional(type_: Any) -> Tuple[bool, Any]:
"""Check whether `type_` is equivalent to `typing.Optional[T]`
for some T.
From https://github.com/omry/omegaconf/blob/e95c2c76d2545a844794682108ded57fbf98f042/omegaconf/_utils.py#L202""" # noqa: E501
From https://github.com/omry/omegaconf/blob/e95c2c76d2545a844794682108ded57fbf98f042/omegaconf/_utils.py#L202
""" # noqa: E501
if is_union_annotation(type_):
args = type_.__args__
if NoneType in args:
Expand Down
1 change: 0 additions & 1 deletion tests/test_memoize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class TestMemoize(unittest.TestCase):
def test_memoize_function(self):

with TemporaryDirectory() as d:

@memoize(cachedir=d)
Expand Down
1 change: 0 additions & 1 deletion tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class TestMerge(unittest.TestCase):
def test_merge_dicts(self):

d1 = from_python({"a": {"c": 4, "d": 5}, "b": 2, "c": 3})
d2 = from_python({"a": {"c": 6, "e": 7}, "b": {"f": 8}})

Expand Down

0 comments on commit e52778e

Please sign in to comment.