zstdlib 0.2.0__tar.gz → 0.3.0__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.
- {zstdlib-0.2.0 → zstdlib-0.3.0}/PKG-INFO +3 -3
- {zstdlib-0.2.0 → zstdlib-0.3.0}/pyproject.toml +11 -24
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/__init__.py +1 -1
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/enum.py +46 -34
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib.egg-info/PKG-INFO +3 -3
- {zstdlib-0.2.0 → zstdlib-0.3.0}/LICENSE +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/README.md +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/setup.cfg +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/__init__.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/log/__init__.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/log/base.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/log/test_cute.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/log/test_trace.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/not_set.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/test_ansi.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/test_enum.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/test_frozen.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/test_io.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/tests/test_singleton.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/ansi.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/frozen.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/io.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/log/__init__.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/log/cute.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/log/trace.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/not_set.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/py.typed +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib/singleton.py +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib.egg-info/SOURCES.txt +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib.egg-info/dependency_links.txt +0 -0
- {zstdlib-0.2.0 → zstdlib-0.3.0}/zstdlib.egg-info/top_level.txt +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zstdlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A set of useful python utilities
|
|
5
5
|
License: GPLv3
|
|
6
6
|
Project-URL: Homepage, https://github.com/zwimer/zstdlib
|
|
7
7
|
Keywords: remote,pipe
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
11
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.14
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Dynamic: license-file
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
name = "zstdlib"
|
|
7
7
|
classifiers = [
|
|
8
8
|
"Programming Language :: Python :: 3",
|
|
9
|
-
"Programming Language :: Python :: 3.
|
|
9
|
+
"Programming Language :: Python :: 3.14",
|
|
10
10
|
"Development Status :: 5 - Production/Stable",
|
|
11
11
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
12
12
|
]
|
|
@@ -14,20 +14,7 @@ keywords = ["remote", "pipe"]
|
|
|
14
14
|
license = {text = "GPLv3"}
|
|
15
15
|
description = "A set of useful python utilities"
|
|
16
16
|
urls = {Homepage = "https://github.com/zwimer/zstdlib"}
|
|
17
|
-
requires-python = ">= 3.
|
|
18
|
-
# dependencies = [
|
|
19
|
-
# # Client
|
|
20
|
-
# "zstandard[cffi]",
|
|
21
|
-
# "pycryptodomex",
|
|
22
|
-
# "cryptography",
|
|
23
|
-
# "requests",
|
|
24
|
-
# "tqdm",
|
|
25
|
-
# # Server
|
|
26
|
-
# "waitress",
|
|
27
|
-
# "flask",
|
|
28
|
-
# # Both
|
|
29
|
-
# "human_readable",
|
|
30
|
-
# ]
|
|
17
|
+
requires-python = ">= 3.14"
|
|
31
18
|
dynamic = ["version"]
|
|
32
19
|
|
|
33
20
|
[project.readme]
|
|
@@ -38,14 +25,14 @@ content-type = "text/markdown"
|
|
|
38
25
|
include-package-data = true
|
|
39
26
|
license-files = ["LICENSE"]
|
|
40
27
|
|
|
41
|
-
[tool.setuptools.packages]
|
|
42
|
-
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
namespaces = false
|
|
43
30
|
|
|
44
31
|
[tool.setuptools.package-data]
|
|
45
32
|
zstdlib = ["py.typed"]
|
|
46
33
|
|
|
47
|
-
[tool.setuptools.dynamic]
|
|
48
|
-
|
|
34
|
+
[tool.setuptools.dynamic.version]
|
|
35
|
+
attr = "zstdlib.__version__"
|
|
49
36
|
|
|
50
37
|
# Tools
|
|
51
38
|
|
|
@@ -55,15 +42,15 @@ ignore-paths = '^tests/.*$'
|
|
|
55
42
|
disable = [
|
|
56
43
|
"unnecessary-lambda-assignment",
|
|
57
44
|
"method-cache-max-size-none",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
"missing-module-docstring",
|
|
46
|
+
"too-few-public-methods",
|
|
47
|
+
"line-too-long",
|
|
48
|
+
"invalid-name"
|
|
62
49
|
]
|
|
63
50
|
|
|
64
51
|
[tool.black]
|
|
65
52
|
line-length = 110
|
|
66
|
-
target-version = ["
|
|
53
|
+
target-version = ["py313"] # py314 when available
|
|
67
54
|
|
|
68
55
|
[tool.ruff]
|
|
69
56
|
line-length = 110
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from collections.abc import Iterator
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import ForwardRef, Any
|
|
3
|
+
import annotationlib
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class _Auto:
|
|
@@ -17,6 +18,7 @@ class EnumType(type):
|
|
|
17
18
|
These 'Enum' classes may not be modified after creation
|
|
18
19
|
Items of annotation types in type_check will be type-checked
|
|
19
20
|
Duplicate values (as determined by set()) are not allowed unless dupes_ok is True
|
|
21
|
+
If dupe-checking is enabled, values must be hashable
|
|
20
22
|
"""
|
|
21
23
|
|
|
22
24
|
_AUTO_PREFIX = "Enum_Auto_"
|
|
@@ -36,38 +38,46 @@ class EnumType(type):
|
|
|
36
38
|
|
|
37
39
|
@classmethod
|
|
38
40
|
def _gen_entries_and_annotations(
|
|
39
|
-
mcs,
|
|
40
|
-
|
|
41
|
+
mcs,
|
|
42
|
+
attrs: dict,
|
|
43
|
+
dupes_ok: bool,
|
|
44
|
+
ans: dict[str, type | ForwardRef],
|
|
45
|
+
) -> dict[str, tuple[type | None, Any]]:
|
|
41
46
|
"""
|
|
42
47
|
Generate enum entries from attrs, checking for duplicates and missing annotations
|
|
43
48
|
Does not check for empty enum or type correctness
|
|
49
|
+
Updates ans with new annotations
|
|
44
50
|
"""
|
|
45
51
|
seen = set()
|
|
46
52
|
auto_val = 0
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
ret = {}
|
|
54
|
+
for a_name, value in ((i, k) for i, k in attrs.items() if not i.startswith("__")):
|
|
55
|
+
# If auto, ensure not annotated, then annotate
|
|
56
|
+
if value is auto:
|
|
57
|
+
auto_val += 1
|
|
58
|
+
value = mcs._AutoValue(auto_val)
|
|
59
|
+
if a_name in ans:
|
|
60
|
+
raise TypeError("Auto enum entries may not be type annotated")
|
|
61
|
+
ans[a_name] = mcs._AutoValue
|
|
62
|
+
# If annotated as auto, complain
|
|
63
|
+
elif isinstance(value, mcs._AutoValue):
|
|
64
|
+
raise ValueError("Enum entries may not be of type EnumType._AutoValue")
|
|
65
|
+
# Dupe check, requires hash-able values
|
|
66
|
+
if not dupes_ok:
|
|
67
|
+
if value in seen:
|
|
68
|
+
raise ValueError(f"Duplicate enum value: {value}")
|
|
69
|
+
try:
|
|
62
70
|
seen.add(value)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
except TypeError:
|
|
72
|
+
raise TypeError(f"Unhashable enum value cannot be dupe checked: {value}") from None
|
|
73
|
+
# Save annotation and value to entries
|
|
74
|
+
try:
|
|
75
|
+
ret[a_name] = (ans[a_name], value)
|
|
76
|
+
except KeyError:
|
|
77
|
+
raise ValueError("Non-auto enum entries must be type annotated") from None
|
|
78
|
+
return ret
|
|
79
|
+
|
|
80
|
+
# pylint: disable=too-many-arguments, dangerous-default-value, too-many-locals
|
|
71
81
|
def __new__(
|
|
72
82
|
mcs,
|
|
73
83
|
name,
|
|
@@ -82,24 +92,26 @@ class EnumType(type):
|
|
|
82
92
|
# Disallow undesired instance methods
|
|
83
93
|
if bad := attrs.keys() & {"__init__", "__new__", "__entries__"}:
|
|
84
94
|
raise AttributeError(f"Illegal methods in Enum class: {', '.join(bad)}")
|
|
85
|
-
# Generate entries
|
|
86
|
-
|
|
95
|
+
# Generate entries and annotations
|
|
96
|
+
ans = annotationlib.get_annotations(super().__new__(mcs, name, bases, attrs))
|
|
97
|
+
entries_ = mcs._gen_entries_and_annotations(attrs, dupes_ok, ans)
|
|
87
98
|
# Validate entries
|
|
88
|
-
if no_value := (
|
|
99
|
+
if no_value := (ans.keys() - entries_.keys()):
|
|
89
100
|
raise ValueError(f"Entries must have a value: {' '.join(no_value)}")
|
|
90
|
-
if (not empty_ok) and not
|
|
101
|
+
if (not empty_ok) and not entries_:
|
|
91
102
|
raise ValueError("Enum type may not be empty")
|
|
92
103
|
if type_check:
|
|
93
|
-
for a_name, (ann, val) in
|
|
104
|
+
for a_name, (ann, val) in entries_.items():
|
|
94
105
|
if ann in type_check and (
|
|
95
106
|
(ann is None is not val) or (ann is not None and not isinstance(val, ann))
|
|
96
107
|
):
|
|
97
108
|
raise TypeError(f"Entry {a_name} is not of type {ann}")
|
|
98
109
|
# Construct class
|
|
99
|
-
attrs["__entries__"] =
|
|
100
|
-
attrs["__annotations__"] = _annotations
|
|
110
|
+
attrs["__entries__"] = entries_ # For our usage later
|
|
101
111
|
attrs["__init__"] = attrs["__new__"] = NotImplemented
|
|
102
|
-
|
|
112
|
+
ret = type.__new__(mcs, name, bases, attrs, **kwargs)
|
|
113
|
+
super().__setattr__(ret, "__annotations__", ans) # Since we disable this method, use super()
|
|
114
|
+
return ret
|
|
103
115
|
|
|
104
116
|
# Disallow modification
|
|
105
117
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zstdlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A set of useful python utilities
|
|
5
5
|
License: GPLv3
|
|
6
6
|
Project-URL: Homepage, https://github.com/zwimer/zstdlib
|
|
7
7
|
Keywords: remote,pipe
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
11
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.14
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Dynamic: license-file
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|