Skip to content

Commit 697a825

Browse files
0.2.8 fix for StrictBool (#30)
1 parent abc26a9 commit 697a825

19 files changed

+200
-57
lines changed

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ ignore =
1313
# E303 too many blank lines
1414
E303,
1515

16+
#--------------------------------------------------------------------------
17+
# PLUGINS
18+
#--------------------------------------------------------------------------
19+
20+
# PT007 wrong values type in @pytest.mark.parametrize, expected list
21+
PT007
22+
23+
1624
max-line-length = 120
1725

1826
exclude =

.github/workflows/run_tox.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@ name: Tests
33
on: [push, pull_request]
44

55
jobs:
6+
pre-commit:
7+
name:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-python@v4
12+
with:
13+
python-version: '3.10'
14+
- uses: pre-commit/[email protected]
15+
16+
617
test:
18+
needs: pre-commit
719
runs-on: ubuntu-latest
820
strategy:
921
max-parallel: 4

.pre-commit-config.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
repos:
2+
23
- repo: https://github.com/pre-commit/pre-commit-hooks
34
rev: v4.4.0
45
hooks:
56
- id: check-yaml
67
- id: end-of-file-fixer
78
- id: trailing-whitespace
89

10+
911
- repo: https://github.com/pycqa/isort
10-
rev: v5.11.3
12+
rev: 5.12.0
1113
hooks:
1214
- id: isort
1315
name: isort (python)
1416

17+
1518
- repo: https://github.com/PyCQA/flake8
1619
rev: '6.0.0'
1720
hooks:
1821
- id: flake8
22+
additional_dependencies:
23+
- flake8-bugbear==23.1.20
24+
- flake8-comprehensions==3.10.1
25+
- flake8-pytest-style==1.6
26+
- flake8-noqa==1.3
27+
- pep8-naming==0.13.3
28+
29+
30+
- repo: meta
31+
hooks:
32+
- id: check-hooks-apply
33+
- id: check-useless-excludes

readme.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,51 +157,54 @@ sub.cancel()
157157
```
158158

159159
# Changelog
160-
#### 0.2.7 (09.01.2023)
160+
#### 0.2.8 (2023-02-08)
161+
- Fix for StrictBool
162+
163+
#### 0.2.7 (2023-01-09)
161164
- Fixed default generation for data types that inherit from python base types
162165

163-
#### 0.2.6 (21.12.2022)
166+
#### 0.2.6 (2022-12-21)
164167
- Fixed an issue where the default yaml file would not be created properly when using aliases in container
165168

166-
#### 0.2.5 (21.10.2022)
169+
#### 0.2.5 (2022-10-21)
167170
- Marked package as PEP 561 compatible (py.typed)
168171

169-
#### 0.2.4 (19.04.2022)
172+
#### 0.2.4 (2022-04-19)
170173
- Default values get validated, too
171174

172-
#### 0.2.3 (08.04.2022)
175+
#### 0.2.3 (2022-04-08)
173176
- Added extra kwargs check for pydantic fields
174177
- Added option to get generated yaml as a string
175178

176-
#### 0.2.2 (31.03.2022)
179+
#### 0.2.2 (2022-03-31)
177180
- Added convenience base classes ``AppBaseModel`` and ``BaseModel``
178181
- Works with private attributes and class functions
179182
- Fixed an issue where multiline comments would not be created properly
180183
- Added an option to exclude entries from config file
181184

182-
#### 0.2.1 (25.03.2022)
185+
#### 0.2.1 (2022-03-25)
183186
- Allow callbacks for file defaults
184187

185-
#### 0.2.0 (25.03.2022)
188+
#### 0.2.0 (2022-03-25)
186189
- Switched to new and more flexible API
187190
- File default and config default are now separated
188191

189-
#### 0.1.2 (08.03.2022)
192+
#### 0.1.2 (2022-03-08)
190193
- Comments get nicely intended
191194
- Fixed an issue with nested data structures
192195
- Allow to specify a different value for file creation
193196

194-
#### 0.1.1 (26.02.2022)
197+
#### 0.1.1 (2022-02-26)
195198
- Fixed an issue with dynamic defaults
196199
- Optional values with default None will not be created in the yaml file
197200

198-
#### 0.1.0 (10.01.2022)
201+
#### 0.1.0 (2022-01-10)
199202
- Updated requirements
200203

201-
#### 0.0.2 (16.09.2021)
204+
#### 0.0.2 (2021-09-16)
202205
- Validate user defaults
203206
- Use json representation of values to get native yaml data types
204207
- Use enum values instead of enum types
205208

206-
#### 0.0.1 (14.09.2021)
209+
#### 0.0.1 (2021-09-14)
207210
- Initial release

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
-r requirements_setup.txt
33

44
# testing dependencies
5-
pytest >= 7.2, < 8
6-
pre-commit >= 2.21, < 3
5+
pytest >= 7.2, < 8
6+
pre-commit >= 3.0, < 3.1

src/easyconfig/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.7'
1+
__version__ = '0.2.8'

src/easyconfig/config_objs/app_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from easyconfig.__const__ import MISSING, MISSING_TYPE
99
from easyconfig.yaml import cmap_from_model, CommentedMap, write_aligned_yaml, yaml_rt
1010

11-
from ..errors import DefaultNotSet
11+
from ..errors import FileDefaultsNotSetError
1212
from .object_config import ConfigObj
1313

1414

@@ -60,7 +60,7 @@ def load_config_file(self, path: Union[Path, str] = None):
6060
def generate_default_yaml(self) -> str:
6161

6262
if self._file_defaults is None:
63-
raise DefaultNotSet()
63+
raise FileDefaultsNotSetError()
6464

6565
buffer = StringIO()
6666
c_map = cmap_from_model(self._file_defaults)

src/easyconfig/config_objs/object_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, model: BaseModel,
3333
self._obj_model_fields: Dict[str, ModelField] = model.__fields__
3434
self._obj_model_private_attrs: List[str] = list(model.__private_attributes__.keys())
3535

36-
self._obj_keys: Tuple[str, ...] = tuple()
36+
self._obj_keys: Tuple[str, ...] = ()
3737
self._obj_values: Dict[str, Any] = {}
3838
self._obj_children: Dict[str, Union[HINT_CONFIG_OBJ, Tuple[HINT_CONFIG_OBJ, ...]]] = {}
3939

@@ -75,7 +75,7 @@ def from_model(cls, model: BaseModel,
7575

7676
if isinstance(value, BaseModel):
7777
ret._obj_children[key] = attrib = cls.from_model(value, path=path + (key,), parent=ret)
78-
elif isinstance(value, tuple) and all(map(lambda x: isinstance(x, BaseModel), value)):
78+
elif isinstance(value, tuple) and all(isinstance(x, BaseModel) for x in value):
7979
ret._obj_children[key] = attrib = tuple(
8080
cls.from_model(o, path=path + (key, str(i)), parent=ret) for i, o in enumerate(value)
8181
)

src/easyconfig/create_app_config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from easyconfig.__const__ import ARG_NAME_IN_FILE, MISSING, MISSING_TYPE
77
from easyconfig.config_objs.app_config import AppConfig, yaml_rt
8-
from easyconfig.errors import ExtraKwArgsNotAllowed
8+
from easyconfig.errors import ExtraKwArgsNotAllowedError
99

1010
TYPE_WRAPPED = TypeVar('TYPE_WRAPPED', bound=BaseModel)
1111
TYPE_DEFAULTS = Union[BaseModel, Dict[str, Any]]
@@ -18,11 +18,13 @@ def check_field_args(model: AppConfig, allowed: FrozenSet[str]):
1818
for name, field in model._obj_model_fields.items():
1919
if not set(field.field_info.extra).issubset(allowed):
2020
forbidden = sorted(set(field.field_info.extra) - allowed)
21-
raise ExtraKwArgsNotAllowed(f'Extra kwargs for field "{name}" of {model._last_model.__class__.__name__} '
22-
f'are not allowed: {", ".join(forbidden)}')
21+
raise ExtraKwArgsNotAllowedError(
22+
f'Extra kwargs for field "{name}" of {model._last_model.__class__.__name__} are not allowed: '
23+
f'{", ".join(forbidden)}'
24+
)
2325

2426
# Submodels
25-
for name, sub_model in model._obj_children.items():
27+
for sub_model in model._obj_children.values():
2628
if isinstance(sub_model, tuple):
2729
for _sub_model in sub_model:
2830
check_field_args(model, allowed)

src/easyconfig/errors/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .errors import DefaultNotSet, DuplicateSubscriptionError, ExtraKwArgsNotAllowed, \
2-
FunctionCallNotAllowedError, SubscriptionAlreadyCanceledError
1+
from .errors import DuplicateSubscriptionError, ExtraKwArgsNotAllowedError, \
2+
FileDefaultsNotSetError, FunctionCallNotAllowedError, SubscriptionAlreadyCanceledError
33
from .handler import set_exception_handler

0 commit comments

Comments
 (0)