Skip to content

Commit 722554d

Browse files
committed
feat: harden file IO helpers and expand test coverage
- improve default, JSON, and TOML IO validation and error handling - add byte read and write support to the default IO helpers - rename the TOML writer export from read_write to write_toml - switch TOML serialization to tomllib and tomli_w - raise the minimum Python version to 3.11 and update dependencies - simplify the .gitignore setup - add a static IO test runner and extend logger, mask, JSON, TOML, and default IO tests
1 parent fdac389 commit 722554d

14 files changed

Lines changed: 652 additions & 457 deletions

.gitignore

Lines changed: 24 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,223 +1,50 @@
1-
# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,pythonvanilla
2-
# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode,pythonvanilla
3-
4-
### Python ###
5-
# Byte-compiled / optimized / DLL files
1+
# Python bytecode and caches
62
__pycache__/
73
*.py[cod]
84
*$py.class
95

10-
# C extensions
11-
*.so
12-
13-
# Distribution / packaging
14-
.Python
15-
build/
16-
develop-eggs/
17-
dist/
18-
downloads/
19-
eggs/
20-
.eggs/
21-
lib/
22-
lib64/
23-
parts/
24-
sdist/
25-
var/
26-
wheels/
27-
share/python-wheels/
28-
*.egg-info/
29-
.installed.cfg
30-
*.egg
31-
MANIFEST
32-
33-
# PyInstaller
34-
# Usually these files are written by a python script from a template
35-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36-
*.manifest
37-
*.spec
38-
39-
# Installer logs
40-
pip-log.txt
41-
pip-delete-this-directory.txt
42-
43-
# Unit test / coverage reports
44-
htmlcov/
6+
# Test, lint, and type-checker caches
7+
.pytest_cache/
8+
.ruff_cache/
9+
.mypy_cache/
10+
.hypothesis/
4511
.tox/
4612
.nox/
4713
.coverage
4814
.coverage.*
49-
.cache
50-
nosetests.xml
15+
htmlcov/
5116
coverage.xml
52-
*.cover
53-
*.py,cover
54-
.hypothesis/
55-
.pytest_cache/
56-
cover/
57-
58-
# Translations
59-
*.mo
60-
*.pot
61-
62-
# Django stuff:
63-
*.log
64-
local_settings.py
65-
db.sqlite3
66-
db.sqlite3-journal
67-
68-
# Flask stuff:
69-
instance/
70-
.webassets-cache
71-
72-
# Scrapy stuff:
73-
.scrapy
74-
75-
# Sphinx documentation
76-
docs/_build/
77-
78-
# PyBuilder
79-
.pybuilder/
80-
target/
81-
82-
# Jupyter Notebook
83-
.ipynb_checkpoints
84-
85-
# IPython
86-
profile_default/
87-
ipython_config.py
88-
89-
# pyenv
90-
# For a library or package, you might want to ignore these files since the code is
91-
# intended to run in multiple environments; otherwise, check them in:
92-
# .python-version
93-
94-
# pipenv
95-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
97-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
98-
# install all needed dependencies.
99-
#Pipfile.lock
100-
101-
# poetry
102-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103-
# This is especially recommended for binary packages to ensure reproducibility, and is more
104-
# commonly ignored for libraries.
105-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106-
#poetry.lock
107-
108-
# pdm
109-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110-
#pdm.lock
111-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112-
# in version control.
113-
# https://pdm.fming.dev/#use-with-ide
114-
.pdm.toml
115-
116-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117-
__pypackages__/
118-
119-
# Celery stuff
120-
celerybeat-schedule
121-
celerybeat.pid
12217

123-
# SageMath parsed files
124-
*.sage.py
18+
# Build and packaging artifacts
19+
build/
20+
dist/
21+
.eggs/
22+
*.egg-info/
23+
*.egg
24+
pip-wheel-metadata/
12525

126-
# Environments
26+
# Virtual environments
12727
.env
128-
.venv
28+
.venv/
12929
env/
13030
venv/
13131
ENV/
132-
env.bak/
133-
venv.bak/
13432

135-
# Spyder project settings
136-
.spyderproject
137-
.spyproject
138-
139-
# Rope project settings
140-
.ropeproject
141-
142-
# mkdocs documentation
143-
/site
144-
145-
# mypy
146-
.mypy_cache/
147-
.dmypy.json
148-
dmypy.json
149-
150-
# Pyre type checker
151-
.pyre/
152-
153-
# pytype static type analyzer
154-
.pytype/
155-
156-
# Cython debug symbols
157-
cython_debug/
158-
159-
# PyCharm
160-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162-
# and can be added to the global gitignore or merged into this file. For a more nuclear
163-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164-
#.idea/
165-
166-
### Python Patch ###
167-
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
33+
# Local tool configuration
16834
poetry.toml
35+
.pdm.toml
16936

170-
# ruff
171-
.ruff_cache/
172-
173-
# LSP config files
174-
pyrightconfig.json
175-
176-
### PythonVanilla ###
177-
# Byte-compiled / optimized / DLL files
178-
179-
# C extensions
180-
181-
# Distribution / packaging
182-
183-
# Installer logs
184-
185-
# Unit test / coverage reports
186-
187-
# Translations
188-
189-
# pyenv
190-
# For a library or package, you might want to ignore these files since the code is
191-
# intended to run in multiple environments; otherwise, check them in:
192-
# .python-version
193-
194-
# pipenv
195-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
196-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
197-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
198-
# install all needed dependencies.
199-
200-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
201-
37+
# Documentation builds
38+
docs/_build/
20239

203-
### VisualStudioCode ###
204-
.vscode/*
40+
# Editors
20541
.vscode/
42+
.vscode/*
20643
!.vscode/settings.json
20744
!.vscode/tasks.json
20845
!.vscode/launch.json
20946
!.vscode/extensions.json
21047
!.vscode/*.code-snippets
211-
212-
# Local History for Visual Studio Code
48+
.idea/
21349
.history/
214-
215-
# Built Visual Studio Code Extensions
216-
*.vsix
217-
218-
### VisualStudioCode Patch ###
219-
# Ignore all local history of files
220-
.history
221-
.ionide
222-
223-
# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,pythonvanilla
50+
.ionide/

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "clevertools"
77
version = "0.2.1"
88
description = "Clevertools is a utility library providing practical tools for common workflows."
99
readme = "README.md"
10-
requires-python = ">=3.10"
10+
requires-python = ">=3.11"
1111
license = "Apache-2.0"
1212
license-files = ["LICENSE", "NOTICE", "CONTRIBUTORS"]
1313
authors = [{ name = "b7binw13" }]

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pytest
33
ruff
44
mypy
5+
faker
56

67
# === For tools to work === #
7-
toml
8+
tomli_w

src/clevertools/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from .file.default_io import read, write
1414
from .file.json_io import read_json, write_json
15-
from .file.toml_io import read_toml, read_write
15+
from .file.toml_io import read_toml, write_toml
1616

1717
from .system.mask_handler import mask
1818

@@ -29,7 +29,7 @@
2929
"read_json",
3030
"write_json",
3131
"read_toml",
32-
"read_write",
32+
"write_toml",
3333
"configure_logger",
3434
"get_logger",
3535
"CleverToolsFormatter",

0 commit comments

Comments
 (0)