Skip to content

Commit fd073f3

Browse files
0.3.1
1 parent 7f3ba32 commit fd073f3

32 files changed

+276
-183
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
repos:
22

33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v4.5.0
55
hooks:
66
- id: check-yaml
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99

10-
11-
- repo: https://github.com/pycqa/isort
12-
rev: 5.12.0
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
# Ruff version.
12+
rev: v0.1.5
1313
hooks:
14-
- id: isort
15-
name: isort (python)
16-
14+
- id: ruff
15+
# - id: ruff-format
1716

1817
- repo: https://github.com/PyCQA/flake8
19-
rev: '6.0.0'
18+
rev: '6.1.0'
2019
hooks:
2120
- id: flake8
2221
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
22+
- flake8-bugbear==23.9.16
23+
- flake8-comprehensions==3.14.0
24+
- flake8-pytest-style==1.7.2
2725
- pep8-naming==0.13.3
2826

29-
3027
- repo: meta
3128
hooks:
3229
- id: check-hooks-apply
3330
- id: check-useless-excludes
3431

3532
- repo: https://github.com/asottile/pyupgrade
36-
rev: v3.9.0
33+
rev: v3.15.0
3734
hooks:
3835
- id: pyupgrade
3936
args: ["--py38-plus"]

.ruff.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
line-length = 120
3+
indent-width = 4
4+
5+
target-version = "py38"
6+
7+
# https://docs.astral.sh/ruff/settings/#ignore-init-module-imports
8+
ignore-init-module-imports = true
9+
src = ["src", "test"]
10+
extend-exclude = ["__init__.py"]
11+
12+
select = [
13+
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
14+
"I", # https://docs.astral.sh/ruff/rules/#isort-i
15+
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
16+
17+
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
18+
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
19+
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
20+
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
21+
"FIX", # https://docs.astral.sh/ruff/rules/#flake8-fixme-fix
22+
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
23+
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
24+
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
25+
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
26+
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
27+
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
28+
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
29+
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
30+
"T10", # https://docs.astral.sh/ruff/rules/#flake8-debugger-t10
31+
"TCH", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
32+
"TD", # https://docs.astral.sh/ruff/rules/#flake8-todos-td
33+
34+
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
35+
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
36+
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
37+
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
38+
39+
# "PL", # https://docs.astral.sh/ruff/rules/#pylint-pl
40+
# "FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
41+
]
42+
43+
ignore = [
44+
"RET501" # https://docs.astral.sh/ruff/rules/unnecessary-return-none/#unnecessary-return-none-ret501
45+
]
46+
47+
48+
[format]
49+
# Use single quotes for non-triple-quoted strings.
50+
quote-style = "single"
51+
52+
53+
[lint.isort]
54+
known-local-folder = ["easyconfig"]
55+
known-first-party = ["tests", "helper"]
56+
57+
58+
[lint.flake8-builtins]
59+
builtins-ignorelist = ["id"]
60+
61+
62+
[lint.per-file-ignores]
63+
"docs/conf.py" = ["INP001", "A001"]
64+
"setup.py" = ["PTH123"]

docs/conf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13-
import os
1413
import sys
14+
from pathlib import Path
15+
16+
src_folder = Path(__file__).parent.with_name('src')
17+
assert src_folder.is_dir()
1518

1619
# required for autodoc
17-
sys.path.insert(0, os.path.join(os.path.abspath('..'), 'src'))
20+
sys.path.insert(0, str(src_folder))
1821

1922
import easyconfig # noqa: E402
2023

2124
# -- Project information -----------------------------------------------------
2225
project = 'easyconfig'
23-
copyright = '2022, spacemanspiff2007'
26+
copyright = '2023, spacemanspiff2007'
2427
author = 'spacemanspiff2007'
2528

2629
# The full version, including alpha/beta/rc tags

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Packages required to build the documentation
2-
sphinx == 6.2.1
3-
sphinx-autodoc-typehints == 1.23.0
4-
sphinx_rtd_theme == 1.2.2
2+
sphinx == 7.2.6
3+
sphinx-autodoc-typehints == 1.25.0
4+
sphinx_rtd_theme == 1.3.0
55
sphinx-exec-code == 0.10

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ That way the users can have some guidance how to change the program behaviour.
4040
It's possible to use environment variable or files for expansion. Easyconfig will load all values
4141

4242
# Changelog
43+
#### 0.3.1 (2023-11-10)
44+
- Updated dependencies and code linters
45+
4346
#### 0.3.0 (2023-03-17)
4447
- Breaking: requires pydantic 2.0
4548
- Added support for variable expansion through environment variables and docker secrets

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33

44
# testing dependencies
55
pytest >= 7.4, < 8
6-
pre-commit >= 3.3, < 4
6+
pre-commit >= 3.5, < 4
7+
8+
# linter
9+
ruff >= 0.1.5, < 0.2

requirements_setup.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pydantic >= 2.0, < 3.0
22
pydantic-settings >= 2.0, < 3.0
3-
ruamel.yaml >= 0.17, < 0.18
3+
ruamel.yaml >= 0.17, < 0.19
44
typing-extensions >= 4.4, < 5

setup.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def load_version() -> str:
88
version: typing.Dict[str, str] = {}
9-
with open("src/easyconfig/__version__.py") as fp:
9+
with open('src/easyconfig/__version__.py') as fp:
1010
exec(fp.read(), version)
1111
assert version['__version__'], version
1212
return version['__version__']
@@ -26,44 +26,38 @@ def load_req() -> typing.List[str]:
2626
readme = Path(__file__).with_name('readme.md')
2727
long_description = ''
2828
if readme.is_file():
29-
with readme.open("r", encoding='utf-8') as fh:
29+
with readme.open('r', encoding='utf-8') as fh:
3030
long_description = fh.read()
3131

3232
setup(
33-
name="easyconfig",
33+
name='easyconfig',
3434
version=__version__,
35-
author="spaceman_spiff",
35+
author='spaceman_spiff',
3636
# author_email="",
37-
description="Easy application configuration with yaml files",
38-
keywords=[
39-
'yaml',
40-
'configuration',
41-
'pydantic',
42-
'settings',
43-
'config'
44-
],
37+
description='Easy application configuration with yaml files',
38+
keywords=['yaml', 'configuration', 'pydantic', 'settings', 'config'],
4539
long_description=long_description,
46-
long_description_content_type="text/markdown",
47-
url="https://github.com/spacemanspiff2007/easyconfig",
40+
long_description_content_type='text/markdown',
41+
url='https://github.com/spacemanspiff2007/easyconfig',
4842
project_urls={
4943
'GitHub': 'https://github.com/spacemanspiff2007/easyconfig',
5044
},
5145
package_dir={'': 'src'},
52-
package_data={'easyconfig': ["py.typed"]},
46+
package_data={'easyconfig': ['py.typed']},
5347
packages=find_packages('src', exclude=['tests*']),
5448
install_requires=load_req(),
5549
python_requires='>=3.8',
5650
classifiers=[
57-
"Development Status :: 4 - Beta",
58-
"Intended Audience :: Developers",
59-
"License :: OSI Approved :: Apache Software License",
60-
"Natural Language :: English",
61-
"Operating System :: OS Independent",
62-
"Programming Language :: Python :: 3.8",
63-
"Programming Language :: Python :: 3.9",
64-
"Programming Language :: Python :: 3.10",
65-
"Programming Language :: Python :: 3.11",
66-
"Programming Language :: Python :: 3 :: Only",
67-
"Topic :: Software Development :: Libraries"
51+
'Development Status :: 4 - Beta',
52+
'Intended Audience :: Developers',
53+
'License :: OSI Approved :: Apache Software License',
54+
'Natural Language :: English',
55+
'Operating System :: OS Independent',
56+
'Programming Language :: Python :: 3.8',
57+
'Programming Language :: Python :: 3.9',
58+
'Programming Language :: Python :: 3.10',
59+
'Programming Language :: Python :: 3.11',
60+
'Programming Language :: Python :: 3 :: Only',
61+
'Topic :: Software Development :: Libraries',
6862
],
6963
)

src/easyconfig/__version__.py

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

src/easyconfig/config_objs/app_config.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1+
from __future__ import annotations
2+
13
from io import StringIO
24
from pathlib import Path
3-
from typing import Optional, Tuple, Union
4-
5-
from pydantic import BaseModel
6-
from typing_extensions import Self
5+
from typing import TYPE_CHECKING
76

7+
from ..errors import FileDefaultsNotSetError
8+
from .object_config import ConfigObj
89
from easyconfig.__const__ import MISSING, MISSING_TYPE
910
from easyconfig.expansion import expand_obj
10-
from easyconfig.yaml import cmap_from_model, CommentedMap, write_aligned_yaml, yaml_rt
11+
from easyconfig.yaml import CommentedMap, cmap_from_model, write_aligned_yaml, yaml_rt
1112

12-
from ..errors import FileDefaultsNotSetError
13-
from .object_config import ConfigObj
13+
if TYPE_CHECKING:
14+
from pydantic import BaseModel
15+
from typing_extensions import Self
1416

1517

1618
class AppConfig(ConfigObj):
17-
def __init__(self, model: BaseModel, path: Tuple[str, ...] = ('__root__',),
18-
parent: Union[MISSING_TYPE, Self] = MISSING):
19+
def __init__(self, model: BaseModel, path: tuple[str, ...] = ('__root__',), parent: MISSING_TYPE | Self = MISSING):
1920
super().__init__(model, path, parent)
2021

21-
self._file_defaults: Optional[BaseModel] = None
22-
self._file_path: Optional[Path] = None
22+
self._file_defaults: BaseModel | None = None
23+
self._file_path: Path | None = None
2324

24-
def set_file_path(self, path: Union[Path, str]):
25+
def set_file_path(self, path: Path | str):
2526
"""Set the path to the configuration file.
2627
If no file extension is specified ``.yml`` will be automatically appended.
2728
@@ -30,7 +31,8 @@ def set_file_path(self, path: Union[Path, str]):
3031
if isinstance(path, str):
3132
path = Path(path)
3233
if not isinstance(path, Path):
33-
raise ValueError(f'Path to configuration file not of type Path: {path} ({type(path)})')
34+
msg = f'Path to configuration file not of type Path: {path} ({type(path)})'
35+
raise TypeError(msg)
3436

3537
self._file_path = path.resolve()
3638
if not self._file_path.suffix:
@@ -52,7 +54,7 @@ def load_config_dict(self, cfg: dict, /, expansion: bool = True):
5254
self._set_values(model_obj)
5355
return self
5456

55-
def load_config_file(self, path: Union[Path, str] = None, expansion: bool = True):
57+
def load_config_file(self, path: Path | str | None = None, expansion: bool = True):
5658
"""Load configuration from a yaml file. If the file does not exist a default file will be created
5759
5860
:param path: Path to file

0 commit comments

Comments
 (0)