pkn 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pkn-0.1.1 → pkn-0.1.2}/PKG-INFO +1 -1
- {pkn-0.1.1 → pkn-0.1.2}/pkn/__init__.py +1 -1
- {pkn-0.1.1 → pkn-0.1.2}/pkn/pydantic/roots.py +4 -4
- {pkn-0.1.1 → pkn-0.1.2}/pkn/tests/pydantic/test_roots.py +8 -0
- {pkn-0.1.1 → pkn-0.1.2}/pyproject.toml +2 -3
- {pkn-0.1.1 → pkn-0.1.2}/.gitignore +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/LICENSE +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/README.md +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/__init__.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/at.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/common.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/journalctl.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/launchctl.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/reboot.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/infra/systemctl.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/pydantic/__init__.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/pydantic/generic.py +0 -0
- {pkn-0.1.1 → pkn-0.1.2}/pkn/tests/test_all.py +0 -0
{pkn-0.1.1 → pkn-0.1.2}/PKG-INFO
RENAMED
@@ -1,12 +1,12 @@
|
|
1
|
-
from typing import Dict as DictType, List as ListType
|
1
|
+
from typing import Dict as DictType, List as ListType, Optional, Union
|
2
2
|
|
3
|
-
from pydantic import BaseModel, RootModel
|
3
|
+
from pydantic import BaseModel, Field, RootModel
|
4
4
|
|
5
5
|
__all__ = ("Dict", "List")
|
6
6
|
|
7
7
|
|
8
8
|
class Dict(RootModel):
|
9
|
-
root: DictType[str, BaseModel]
|
9
|
+
root: Optional[DictType[str, Optional[Union[BaseModel, "Dict", "List", int, float, str]]]] = Field(default_factory=dict)
|
10
10
|
|
11
11
|
def __iter__(self):
|
12
12
|
return iter(self.root)
|
@@ -46,7 +46,7 @@ class Dict(RootModel):
|
|
46
46
|
|
47
47
|
|
48
48
|
class List(RootModel):
|
49
|
-
root: ListType[BaseModel]
|
49
|
+
root: Optional[ListType[Union[BaseModel, "Dict", "List", int, float, str]]] = Field(default_factory=list)
|
50
50
|
|
51
51
|
def __iter__(self):
|
52
52
|
return iter(self.root)
|
@@ -27,6 +27,10 @@ class TestPydanticRoots:
|
|
27
27
|
assert "a" not in d
|
28
28
|
assert "b" not in d
|
29
29
|
|
30
|
+
def test_dict_types(self):
|
31
|
+
d = Dict({"a": MyModel(a=1, b="b"), "b": "abc", "c": 1, "d": 1.2, "e": List(), "f": Dict(), "g": None})
|
32
|
+
assert len(d) == 7
|
33
|
+
|
30
34
|
def test_list(self):
|
31
35
|
lst = List([MyModel(a=1, b="b"), MyModel(a=2, b="c")])
|
32
36
|
assert len(lst) == 2
|
@@ -37,3 +41,7 @@ class TestPydanticRoots:
|
|
37
41
|
del lst[0]
|
38
42
|
assert len(lst) == 1
|
39
43
|
assert lst[0] == MyModel(a=2, b="c")
|
44
|
+
|
45
|
+
def test_list_types(self):
|
46
|
+
d = List([MyModel(a=1, b="b"), "abc", 1, 1.2, List(), Dict(), None])
|
47
|
+
assert len(d) == 7
|
@@ -8,7 +8,7 @@ authors = [{name = "the pkn authors", email = "t.paine154@gmail.com"}]
|
|
8
8
|
description = "My Pocket Knife"
|
9
9
|
readme = "README.md"
|
10
10
|
license = { text = "Apache-2.0" }
|
11
|
-
version = "0.1.
|
11
|
+
version = "0.1.2"
|
12
12
|
requires-python = ">=3.9"
|
13
13
|
keywords = []
|
14
14
|
|
@@ -50,7 +50,7 @@ Repository = "https://github.com/1kbgz/pkn"
|
|
50
50
|
Homepage = "https://github.com/1kbgz/pkn"
|
51
51
|
|
52
52
|
[tool.bumpversion]
|
53
|
-
current_version = "0.1.
|
53
|
+
current_version = "0.1.2"
|
54
54
|
commit = true
|
55
55
|
tag = true
|
56
56
|
|
@@ -101,7 +101,6 @@ packages = ["pkn"]
|
|
101
101
|
|
102
102
|
[tool.pytest.ini_options]
|
103
103
|
addopts = ["-vvv", "--junitxml=junit.xml"]
|
104
|
-
asyncio_mode = "strict"
|
105
104
|
testpaths = "pkn/tests"
|
106
105
|
|
107
106
|
[tool.ruff]
|
File without changes
|
{pkn-0.1.1 → pkn-0.1.2}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|