Skip to content

Commit f95156b

Browse files
Thomas Rabaixrande
authored andcommitted
fix(import): fix import usage
1 parent 6f8af6c commit f95156b

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

Makefile

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
all: build
22

3-
build: clean
4-
pip install build twine
3+
build-install:
4+
uv pip install build twine flake8 sphinx
5+
6+
build: build-install clean
57
rm -rf dist/
6-
python -m build
7-
twine check dist/*
8+
uv run python -m build
9+
uv run twine check dist/*
810

9-
upload-prod: build
11+
upload-prod: build-install build
1012
export TWINE_USERNAME=__token__
11-
bash -c 'read -s -p "Enter your Production PyPI token: " TWINE_PASSWORD; echo; export TWINE_PASSWORD; python -m twine upload dist/*'
13+
bash -c 'read -s -p "Enter your Production PyPI token: " TWINE_PASSWORD; echo; export TWINE_PASSWORD; uv run twine upload dist/*'
1214

13-
upload-test: build
15+
upload-test: build-install build
1416
export TWINE_USERNAME=__token__
15-
bash -c 'read -s -p "Enter your Test PyPI token: " TWINE_PASSWORD; echo; export TWINE_PASSWORD; python -m twine upload --repository testpypi dist/*'
17+
bash -c 'read -s -p "Enter your Test PyPI token: " TWINE_PASSWORD; echo; export TWINE_PASSWORD; uv run twine upload --repository testpypi dist/*'
1618

1719
clean:
1820
rm -rf build/ dist/ *.egg-info/ __pycache__/ .pytest_cache/ .mypy_cache/
1921
find . -type f -name "*.pyc" -delete
2022
find . -type d -name "__pycache__" -delete
2123

22-
test:
23-
flake8 ioc/ tests/
24-
python -m unittest discover -s tests -p "test_*.py"
25-
sphinx-build -nW -b html -d docs/_build/doctrees docs docs/_build/html
24+
test: build-install
25+
uv run flake8 ioc/ tests/
26+
uv run python -m unittest discover -s tests -p "test_*.py"
27+
LC_ALL=C.UTF-8 LANG=C.UTF-8 uv run sphinx-build -nW -b html -d docs/_build/doctrees docs docs/_build/html
2628

27-
test-strict:
28-
flake8 ioc/ tests/
29-
mypy ioc/
30-
python -m unittest discover -s tests -p "test_*.py"
31-
sphinx-build -nW -b html -d docs/_build/doctrees docs docs/_build/html
29+
test-strict: build-install
30+
uv run flake8 ioc/ tests/
31+
uv run mypy ioc/
32+
uv run python -m unittest discover -s tests -p "test_*.py"
33+
LC_ALL=C.UTF-8 LANG=C.UTF-8 uv run sphinx-build -nW -b html -d docs/_build/doctrees docs docs/_build/html
3234

33-
lint:
34-
flake8 ioc/ tests/
35+
lint: build-install
36+
uv run flake8 ioc/ tests/
3537

36-
typecheck:
37-
mypy ioc/
38+
typecheck: build-install
39+
uv run mypy ioc/
3840

39-
unittest:
40-
python -m unittest discover -s tests -p "test_*.py" -v
41+
unittest: build-install
42+
uv run python -m unittest discover -s tests -p "test_*.py" -v

ioc/loader.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@
1717
import yaml
1818

1919
from ioc.component import Definition, Reference, WeakReference, ContainerBuilder
20-
import ioc.helper
2120
import ioc.exceptions
22-
from . import misc
23-
24-
from .misc import OrderedDictYAMLLoader
21+
import ioc.misc
2522

2623
class Loader(object):
27-
def fix_config(self, config: dict[str, Any]) -> 'ioc.helper.Dict':
24+
def fix_config(self, config: dict[str, Any]) -> 'ioc.misc.Dict':
2825
for key, value in config.items():
2926
if isinstance(value, dict):
3027
config[key] = self.fix_config(value)
3128

32-
return ioc.helper.Dict(config)
29+
return ioc.misc.Dict(config)
3330

3431
class YamlLoader(Loader):
3532
def support(self, file: str) -> bool:
@@ -42,7 +39,7 @@ def load(self, file: str, container_builder: ContainerBuilder) -> None:
4239
content = f.read()
4340

4441
try:
45-
data = yaml.load(content, OrderedDictYAMLLoader)
42+
data = yaml.load(content, ioc.misc.OrderedDictYAMLLoader)
4643
except yaml.scanner.ScannerError as e:
4744
raise ioc.exceptions.LoadingError("file %s, \nerror: %s" % (file, e))
4845

@@ -109,23 +106,23 @@ def load(self, file: str, container_builder: ContainerBuilder) -> None:
109106
container_builder.add(id, definition)
110107

111108
def set_reference(self, value: Any) -> Any:
112-
if misc.is_scalar(value) and value[0:1] == '@':
109+
if ioc.misc.is_string(value) and value[0:1] == '@':
113110
if '#' in value:
114111
id, method = value.split("#")
115112
return Reference(id[1:], method)
116113

117114
return Reference(value[1:])
118115

119-
if misc.is_scalar(value) and value[0:2] == '#@':
116+
if ioc.misc.is_string(value) and value[0:2] == '#@':
120117
return WeakReference(value[2:])
121118

122-
if misc.is_iterable(value):
119+
if ioc.misc.is_iterable(value):
123120
return self.set_references(value)
124121

125122
return value
126123

127124
def set_references(self, arguments: Union[list[Any], dict[str, Any]]) -> Union[list[Any], dict[str, Any]]:
128-
for pos in misc.get_keys(arguments):
125+
for pos in ioc.misc.get_keys(arguments):
129126
arguments[pos] = self.set_reference(arguments[pos])
130127

131128
return arguments

ioc/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def deepcopy(value: Any) -> Any:
6464

6565
return value
6666

67-
def is_scalar(value: Any) -> bool:
67+
def is_string(value: Any) -> bool:
6868
return isinstance(value, (str))
6969

7070
def is_iterable(value: Any) -> bool:

0 commit comments

Comments
 (0)