Skip to content

Commit 36f7579

Browse files
committed
Renamed project to 'tomlval'
1 parent 4c18f41 commit 36f7579

16 files changed

+21
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# TOML Parser
1+
# tomlval
22

33
A simple and easy to use TOML parser and validator for Python.

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "toml_parser"
2+
name = "tomlval"
33
version = "1.0.0"
44
description = "A simple and easy to use TOML parser and validator for Python."
55
authors = [
@@ -14,7 +14,7 @@ license = { file = "LICENSE" }
1414
requires-python = ">=3.11"
1515
readme = "README.md"
1616
dependencies = []
17-
keywords = ["toml", "parser", "validator", "python"]
17+
keywords = ["toml", "validator", "validation", "parser", "python"]
1818

1919
[project.optional-dependencies]
2020
build = ["build", "twine"]
@@ -31,7 +31,7 @@ requires = ["setuptools", "wheel"]
3131
build-backend = "setuptools.build_meta"
3232

3333
[tool.setuptools]
34-
packages = ["toml_parser"]
34+
packages = ["tomlval"]
3535

3636
[tool.black]
3737
line-length = 80

tests/test_key_pattern.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from toml_parser.utils.regex import key_pattern
7+
from tomlval.utils.regex import key_pattern
88

99
# Paths
1010
data_path = pathlib.Path(__file__).parent / "data"

tests/test_utils_is_toml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import tomllib
44
from io import BytesIO
55

6-
from toml_parser.utils.is_toml import is_toml
6+
from tomlval.utils.is_toml import is_toml
77

88

99
class DummyPath:

tests/test_utils_to_path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from toml_parser.utils.to_path import to_path
8+
from tomlval.utils.to_path import to_path
99

1010

1111
def test_to_path_with_pathlib_path():
File renamed without changes.
File renamed without changes.
File renamed without changes.

toml_parser/toml_validator.py tomlval/toml_validator.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import re
55
from typing import Any, Callable
66

7-
from toml_parser.errors import TOMLHandlerError
8-
from toml_parser.types import Handler
7+
from tomlval.errors import TOMLHandlerError
8+
from tomlval.types import Handler
9+
from tomlval.utils.regex import key_pattern
910

1011

1112
class TOMLValidator:
@@ -127,6 +128,7 @@ def add_handler(self, key: str, handler: Handler):
127128
Returns:
128129
None
129130
Raises:
131+
ValueError - If the key has an invalid format.
130132
TypeError - If key is not a string.
131133
toml_parser.errors.TOMLHandlerError - If the handler is invalid.
132134
"""
@@ -140,6 +142,14 @@ def add_handler(self, key: str, handler: Handler):
140142
if not isinstance(handler, Callable):
141143
raise TOMLHandlerError("Handler must be a callable.")
142144

145+
# Key type
146+
if not isinstance(key, str):
147+
raise TypeError("Key must be a string.")
148+
149+
# Invalid key
150+
if not key_pattern.match(key):
151+
raise ValueError(f"Invalid key '{key}'.")
152+
143153
# Check if arguments are valid
144154
args = self._inspect_function(handler)
145155

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

toml_parser/utils/is_toml.py tomlval/utils/is_toml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import tomllib
44

5-
from toml_parser.types import PathOrStr
5+
from tomlval.types import PathOrStr
66

77
from .to_path import to_path
88

File renamed without changes.

toml_parser/utils/to_path.py tomlval/utils/to_path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import pathlib
55

6-
from toml_parser.types import PathOrStr
6+
from tomlval.types import PathOrStr
77

88

99
def to_path(path_or_str: PathOrStr) -> pathlib.Path:

0 commit comments

Comments
 (0)