Skip to content

Commit 894b100

Browse files
committed
replaced external toml lib with tomlib
debase. All tests are now passing. Here's a summary of the changes made: Updated imports in all three files to use tomllib instead of toml: src/dotcat/version.py src/dotcat/output_formatters.py src/dotcat/parsers.py Made necessary API adjustments: Updated file handling to use binary mode with open("rb") since tomllib requires bytes input Changed exception handling from toml.TomlDecodeError to tomllib.TOMLDecodeError Implemented a custom TOML writer in output_formatters.py: Since tomllib is read-only and doesn't provide writing capabilities Created a comprehensive TOML writer that handles complex nested structures Ensured the output format matches exactly what the tests expect Updated tests: Fixed mocked functions in test_version.py to use tomllib.load instead of toml.load Updated pyproject.toml: Removed the toml dependency from dev dependencies Updated the Python requirement to >=3.11 since tomllib is only available in Python 3.11+ All tests are now passing, confirming that the migration from toml to tomllib was successful.
1 parent cbee389 commit 894b100

File tree

6 files changed

+131
-112
lines changed

6 files changed

+131
-112
lines changed

poetry.lock

Lines changed: 6 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ version = "0.9.4"
1313
name = "dotcat"
1414
readme = { file = "README.md", content-type = "text/markdown" }
1515
description = "Cat structured data , in style"
16-
requires-python = ">=3.9"
16+
requires-python = ">=3.11"
1717
license = { text = "MIT" }
1818
authors = [{ name = "Arthur Debert", email = "arthur@debert.xzy" }]
1919
classifiers = [
@@ -27,7 +27,6 @@ dependencies = ["pyyaml>=6.0.2"]
2727
[project.optional-dependencies]
2828
dev = [
2929
"homebrew-pypi-poet>=0.10.0",
30-
"toml>=0.10.2",
3130
"build>=1.2.2.post1",
3231
"asttokens>=2.4.1",
3332
"certifi>=2024.6.2",

src/dotcat/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from importlib import metadata
22
import pathlib
3-
import toml
3+
import tomllib
44

55

66
def get_version_from_toml():
@@ -20,7 +20,7 @@ def get_version_from_toml():
2020

2121
if pyproject_path.exists():
2222
# Parse pyproject.toml using the toml library
23-
pyproject_data = toml.load(pyproject_path)
23+
pyproject_data = tomllib.load(pyproject_path.open("rb"))
2424
return pyproject_data.get("project", {}).get("version", "unknown")
2525
except Exception:
2626
pass

0 commit comments

Comments
 (0)