Skip to content

Commit

Permalink
Update todo and format
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagusiak committed May 9, 2024
1 parent 0fdc832 commit 58a4893
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# E123,E133: ignored by default by pep8, so we ignore them here
# E203: space before comma, not pep8 compliant
# E241,E242: spacing after a comma - not used
# F401: module imported but unused
# E701,E704: multiple statements on one line - handled by black
# F812: list comprehension redefines name
# W503: line break before operator - ignored as W504 is in pep8
# * Documentation (https://pep257.readthedocs.io/en/latest/error_codes.html)
Expand All @@ -15,7 +15,7 @@
# D205: 1 blank line required between summary line and description
# D210: no whitespaces allowed surrounding docstring text - not used
# D400: first line should end with a period
ignore = C901,E123,E133,E203,F812,W503,D102,D205,D400
ignore = C901,E123,E133,E203,E701,E704,F812,W503,D102,D205,D400
max-line-length = 100
exclude = .venv,venv,.git
max-complexity = 10
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ __pycache__
dist
.ipynb_checkpoints
*.egg-info
.mypy_cache
.pytest_cache
/*_cache
4 changes: 2 additions & 2 deletions alphaconf/inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def getter(
ktype = next(type_from_annotation(ptype), None)
if param is not None and param.default is not param.empty:
xparam = param
return (
lambda: xparam.default
return lambda: (
xparam.default
if (value := alphaconf.get(key, ktype, default=None)) is None
and xparam.default is not xparam.empty
else value
Expand Down
9 changes: 3 additions & 6 deletions alphaconf/internal/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def get(
type: Type[T],
*,
default: Union[T, RaiseOnMissingType] = raise_on_missing,
) -> T:
...
) -> T: ...

@overload
def get(
Expand All @@ -65,8 +64,7 @@ def get(
type: Union[str, None] = None,
*,
default: Any = raise_on_missing,
) -> Any:
...
) -> Any: ...

@overload
def get(
Expand All @@ -75,8 +73,7 @@ def get(
type: None = None,
*,
default: Union[T, RaiseOnMissingType] = raise_on_missing,
) -> T:
...
) -> T: ...

def get(self, key: Union[str, Type], type=None, *, default=raise_on_missing):
"""Get a configuation value and cast to the correct type"""
Expand Down
1 change: 1 addition & 0 deletions example-inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ def doit(ctx, param=None):

# add some default configuration and run/configure invoke's namespace
alphaconf.setup_configuration({'backup': 'all'})
# TODO just setup logging and load variables into ns?
alphaconf.invoke.run(__name__, globals())
1 change: 0 additions & 1 deletion example-plumbum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@app.command()
def main():
"""Simple demo of alphaconf with plumbum"""

log = logging.getLogger(__name__)
cmd = plumbum.local[alphaconf.get("cmd")]
log.info("Running a command %s", cmd)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dynamic = ["version"]
description = "Write simple scripts leveraging omegaconf"
readme = "README.md"
keywords = ["configuration", "omegaconf", "pydantic", "script"]
license = {text = "BSD License"}
license = {file = "LICENSE"}
requires-python = ">=3.9"
classifiers = [
# https://pypi.org/pypi?%3Aaction=list_classifiers
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Build tools
setuptools
setuptools_scm
black
flake8
isort
black>=22
flake8>=7
isort>=5
mypy
pytest
types-toml
Expand Down

0 comments on commit 58a4893

Please sign in to comment.