zstdlib 0.3.0__tar.gz → 0.3.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.
Files changed (31) hide show
  1. {zstdlib-0.3.0 → zstdlib-0.3.2}/PKG-INFO +1 -1
  2. {zstdlib-0.3.0 → zstdlib-0.3.2}/pyproject.toml +1 -1
  3. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/test_frozen.py +8 -2
  4. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/__init__.py +1 -1
  5. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/ansi.py +31 -34
  6. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/enum.py +2 -2
  7. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/log/cute.py +0 -1
  8. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib.egg-info/PKG-INFO +1 -1
  9. {zstdlib-0.3.0 → zstdlib-0.3.2}/LICENSE +0 -0
  10. {zstdlib-0.3.0 → zstdlib-0.3.2}/README.md +0 -0
  11. {zstdlib-0.3.0 → zstdlib-0.3.2}/setup.cfg +0 -0
  12. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/__init__.py +0 -0
  13. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/log/__init__.py +0 -0
  14. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/log/base.py +0 -0
  15. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/log/test_cute.py +0 -0
  16. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/log/test_trace.py +0 -0
  17. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/not_set.py +0 -0
  18. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/test_ansi.py +0 -0
  19. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/test_enum.py +0 -0
  20. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/test_io.py +0 -0
  21. {zstdlib-0.3.0 → zstdlib-0.3.2}/tests/test_singleton.py +0 -0
  22. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/frozen.py +0 -0
  23. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/io.py +0 -0
  24. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/log/__init__.py +0 -0
  25. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/log/trace.py +0 -0
  26. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/not_set.py +0 -0
  27. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/py.typed +0 -0
  28. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib/singleton.py +0 -0
  29. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib.egg-info/SOURCES.txt +0 -0
  30. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib.egg-info/dependency_links.txt +0 -0
  31. {zstdlib-0.3.0 → zstdlib-0.3.2}/zstdlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zstdlib
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: A set of useful python utilities
5
5
  License: GPLv3
6
6
  Project-URL: Homepage, https://github.com/zwimer/zstdlib
@@ -50,7 +50,7 @@ disable = [
50
50
 
51
51
  [tool.black]
52
52
  line-length = 110
53
- target-version = ["py313"] # py314 when available
53
+ target-version = ["py314"]
54
54
 
55
55
  [tool.ruff]
56
56
  line-length = 110
@@ -1,4 +1,5 @@
1
1
  # pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring,unused-variable,attribute-defined-outside-init
2
+ from sys import version_info
2
3
  import unittest
3
4
 
4
5
  from zstdlib.frozen import Freezable, frozen
@@ -104,10 +105,15 @@ class TestFrozen(unittest.TestCase):
104
105
  f1 = F1()
105
106
  self.assertEqual(f1.__init__.__doc__.strip(), "init doc")
106
107
  self.assertEqual(f1.__init__.__name__, "__init__")
107
- self.assertEqual(f1.__init__.__qualname__, "TestFrozen.test_metadata.<locals>.F2.__init__")
108
+ self.assertEqual(f1.__init__.__qualname__, "TestFrozen.test_metadata.<locals>.F1.__init__")
108
109
  self.assertTupleEqual(f1.__init__.__defaults__, (1,))
109
110
  self.assertDictEqual(f1.__init__.__kwdefaults__, {"b": False})
110
- self.assertDictEqual(f1.__init__.__annotations__, {"a": int, "b": bool, "return": None})
111
+ if version_info <= (3, 13) or hasattr(f1.__init__, "__annotations__"):
112
+ self.assertDictEqual(f1.__init__.__annotations__, {"a": int, "b": bool, "return": None})
113
+ else: # annotations changed in 3.14, .__annotations__ *might* not exist
114
+ from annotationlib import get_annotations
115
+
116
+ self.assertDictEqual(get_annotations(f1.__init__), {"a": int, "b": bool, "return": None})
111
117
 
112
118
  def test_frozen_custom(self):
113
119
  @frozen("custom")
@@ -1,4 +1,4 @@
1
- __version__ = "0.3.0"
1
+ __version__ = "0.3.2"
2
2
 
3
3
  from .not_set import NotSetType, NotSet
4
4
  from .frozen import Freezable, frozen
@@ -39,15 +39,43 @@ class RawColor:
39
39
  self.background = background
40
40
  self.value = self.color.value + (10 if self.background else 0) + (60 if self.bright else 0)
41
41
 
42
+ @classmethod
43
+ @cache
44
+ def _parse_color(cls, item: str) -> str:
45
+ """Construct a color following the rules defined by Color"""
46
+ item = item.lower()
47
+ if "bright_bg" in item:
48
+ raise ValueError("bg_ must precede bright_ in color specification")
49
+ pat = f"(:?bright_)?({'|'.join(list(PureColor.__members__))})"
50
+ shx = re.findall(f"(bg_){pat}", item)
51
+ if len(shx) > 1:
52
+ raise ValueError(f"Multiple background colors specified in {item}")
53
+ bg = None
54
+ if len(shx) == 1:
55
+ item = item.replace("".join(shx[0]), "")
56
+ bg = cls(shx[0][-1], bright="bright_" in shx[0], background=True)
57
+ shx = re.findall(pat, item)
58
+ if len(shx) > 1:
59
+ raise ValueError(f"Multiple foreground colors specified in {item}")
60
+ fg = None
61
+ if len(shx) == 1:
62
+ item = item.replace("".join(shx[0]), "")
63
+ fg = cls(shx[0][-1], bright="bright_" in shx[0])
64
+ # Determine modifiers and construct the color
65
+ attrs = [i for i in item.split("_") if i]
66
+ if any(bad := [i for i in attrs if i not in MODIFIERS]):
67
+ raise ValueError(f"Unknown modifiers(s): {', '.join(bad)}")
68
+ return _generate_code(fg, bg, {i: True for i in MODIFIERS if i in attrs})
69
+
42
70
 
43
71
  class _ColorMeta(type):
44
72
  """
45
73
  A metaclass that implements __getattr__ at the class level for Color
46
74
  """
47
75
 
48
- def __getattr__(cls, item: str) -> "Color":
76
+ def __getattr__(cls, item: str) -> Color:
49
77
  try:
50
- return cls(code=_parse_color(item))
78
+ return cls(code=RawColor._parse_color(item))
51
79
  except ValueError as e:
52
80
  raise AttributeError(str(e)) from e
53
81
 
@@ -91,7 +119,7 @@ class Color(metaclass=_ColorMeta):
91
119
  elif isinstance(fmt, RawColor):
92
120
  self.code = f"{_PREFIX}{fmt.value}m"
93
121
  else:
94
- self.code = _parse_color(fmt) if isinstance(fmt, str) else fmt.code
122
+ self.code = RawColor._parse_color(fmt) if isinstance(fmt, str) else fmt.code
95
123
 
96
124
  def __call__(self, string: str) -> str:
97
125
  """
@@ -145,34 +173,3 @@ def _generate_code(
145
173
  if background:
146
174
  ints.append(background.value)
147
175
  return f"{_PREFIX}{';'.join(map(str, ints))}m"
148
-
149
-
150
- @cache
151
- def _parse_color(item: str) -> str:
152
- """
153
- Construct a color following the rules defined by Color
154
- This method is not a classmethod since python3.13 deprecates mixing classmethod and cache
155
- """
156
- item = item.lower()
157
- if "bright_bg" in item:
158
- raise ValueError("bg_ must precede bright_ in color specification")
159
- pat = f"(:?bright_)?({'|'.join(list(PureColor.__members__))})"
160
- shx = re.findall(f"(bg_){pat}", item)
161
- if len(shx) > 1:
162
- raise ValueError(f"Multiple background colors specified in {item}")
163
- bg: RawColor | None = None
164
- if len(shx) == 1:
165
- item = item.replace("".join(shx[0]), "")
166
- bg = RawColor(shx[0][-1], bright="bright_" in shx[0], background=True)
167
- shx = re.findall(pat, item)
168
- if len(shx) > 1:
169
- raise ValueError(f"Multiple foreground colors specified in {item}")
170
- fg: RawColor | None = None
171
- if len(shx) == 1:
172
- item = item.replace("".join(shx[0]), "")
173
- fg = RawColor(shx[0][-1], bright="bright_" in shx[0])
174
- # Determine modifiers and construct the color
175
- attrs = [i for i in item.split("_") if i]
176
- if any(bad := [i for i in attrs if i not in MODIFIERS]):
177
- raise ValueError(f"Unknown modifiers(s): {', '.join(bad)}")
178
- return _generate_code(fg, bg, {i: True for i in MODIFIERS if i in attrs})
@@ -1,5 +1,5 @@
1
1
  from collections.abc import Iterator
2
- from typing import ForwardRef, Any
2
+ from typing import Any
3
3
  import annotationlib
4
4
 
5
5
 
@@ -41,7 +41,7 @@ class EnumType(type):
41
41
  mcs,
42
42
  attrs: dict,
43
43
  dupes_ok: bool,
44
- ans: dict[str, type | ForwardRef],
44
+ ans: dict[str, type | None],
45
45
  ) -> dict[str, tuple[type | None, Any]]:
46
46
  """
47
47
  Generate enum entries from attrs, checking for duplicates and missing annotations
@@ -1,4 +1,3 @@
1
- from __future__ import annotations
2
1
  from logging import CRITICAL, ERROR, WARNING, INFO, DEBUG, Formatter
3
2
  from collections import defaultdict
4
3
  from typing import TYPE_CHECKING
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zstdlib
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: A set of useful python utilities
5
5
  License: GPLv3
6
6
  Project-URL: Homepage, https://github.com/zwimer/zstdlib
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