moat-lib-path 0.3.5__tar.gz → 0.3.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moat-lib-path
3
- Version: 0.3.5
3
+ Version: 0.3.7
4
4
  Summary: Hierarchical path representation and manipulation for MoaT
5
5
  Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Project-URL: homepage, https://m-o-a-t.org
@@ -1,3 +1,15 @@
1
+ moat-lib-path (0.3.7-1) unstable; urgency=medium
2
+
3
+ * New release for 26.4.27
4
+
5
+ -- Matthias Urlichs <matthias@urlichs.de> Sat, 03 Oct 2026 14:53:15 +0200
6
+
7
+ moat-lib-path (0.3.6-1) unstable; urgency=medium
8
+
9
+ * New release for 26.4.26
10
+
11
+ -- Matthias Urlichs <matthias@urlichs.de> Sat, 03 Oct 2026 12:53:26 +0200
12
+
1
13
  moat-lib-path (0.3.5-1) unstable; urgency=medium
2
14
 
3
15
  * New release for 26.4.0
@@ -22,7 +22,7 @@ name = "moat-lib-path"
22
22
  maintainers = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
23
23
  description='Hierarchical path representation and manipulation for MoaT'
24
24
  readme = "README.md"
25
- version = "0.3.5"
25
+ version = "0.3.7"
26
26
 
27
27
  [project.urls]
28
28
  homepage = "https://m-o-a-t.org"
@@ -53,11 +53,11 @@ from collections.abc import Sequence
53
53
  from typing import TYPE_CHECKING, Literal, TypeAlias, cast, overload
54
54
 
55
55
  if TYPE_CHECKING:
56
- from typing import Any, Literal
56
+ from typing import Any
57
57
 
58
58
  PathTuple: TypeAlias = tuple["PathElem", ...]
59
- PathElem: TypeAlias = None | bool | int | float | str | bytes | PathTuple
60
- PathElemI: TypeAlias = None | bool | int | float | str | bytes | tuple
59
+ PathElem: TypeAlias = bool | int | float | str | bytes | PathTuple | None
60
+ PathElemI: TypeAlias = bool | int | float | str | bytes | tuple | None
61
61
 
62
62
  __all__ = [
63
63
  "PS",
@@ -78,7 +78,7 @@ _PartRE = re.compile("[^:._]+|_|:|\\.")
78
78
  _RTagRE = re.compile("^:m[^:._]+:$")
79
79
 
80
80
 
81
- def set_root(cfg):
81
+ def set_root(cfg) -> None:
82
82
  """
83
83
  Utility to force-set the root global.
84
84
 
@@ -176,7 +176,7 @@ class Path(Sequence[PathElem]):
176
176
  prefix: RootPath | Literal[True] | None = None,
177
177
  decoded: bool = False,
178
178
  _warn: bool = True,
179
- ):
179
+ ) -> None:
180
180
  """
181
181
  Create a path from the given elements.
182
182
 
@@ -196,14 +196,20 @@ class Path(Sequence[PathElem]):
196
196
  if mark:
197
197
  warnings.warn("Marking a path is deprecated")
198
198
 
199
- if _warn and a:
199
+ if not a:
200
+ pass
201
+ elif decoded and isinstance(a[0], RootPath) and prefix is None:
202
+ prefix = a[0]
203
+ a = a[1:]
204
+ elif isinstance(a[0], Path):
205
+ if len(a) > 1:
206
+ raise ValueError("Can't build a path this way")
207
+ a = a[0].as_tuple()
208
+ elif len(a) != 1 and _warn:
200
209
  warnings.warn(
201
210
  "Call 'Path.build(args)', not 'Path(*args)'", DeprecationWarning, stacklevel=2
202
211
  )
203
212
 
204
- if decoded and a and isinstance(a[0], RootPath) and prefix is None:
205
- prefix = a[0]
206
- a = a[1:]
207
213
  for x in a:
208
214
  if not isinstance(x, PathElemI): # pyright:ignore[reportArgumentType]
209
215
  raise TypeError(f"{x!r} cannot be in a path")
@@ -609,10 +615,10 @@ class Path(Sequence[PathElem]):
609
615
 
610
616
  # TODO add alternate output with hex integers
611
617
 
612
- def __repr__(self):
618
+ def __repr__(self) -> str:
613
619
  return f"P({str(self)!r})"
614
620
 
615
- def __format__(self, spec):
621
+ def __format__(self, spec) -> str:
616
622
  return str(self).__format__(spec)
617
623
 
618
624
  @classmethod
@@ -650,7 +656,7 @@ class Path(Sequence[PathElem]):
650
656
  raise SyntaxError(f"Conflicting tags: {mark} vs. {mp[0][2:-1]}")
651
657
  return cls(mark=mark)
652
658
 
653
- def add(x):
659
+ def add(x) -> None:
654
660
  nonlocal part
655
661
  if not isinstance(part, str):
656
662
  part = ""
@@ -659,7 +665,7 @@ class Path(Sequence[PathElem]):
659
665
  except TypeError:
660
666
  raise SyntaxError(f"Cannot add {x!r} at {pos}") from None
661
667
 
662
- def done(new_part):
668
+ def done(new_part) -> None:
663
669
  nonlocal part
664
670
  nonlocal eval_
665
671
  if isinstance(part, str):
@@ -681,7 +687,7 @@ class Path(Sequence[PathElem]):
681
687
  res.append(part)
682
688
  part = new_part
683
689
 
684
- def new(x):
690
+ def new(x) -> None:
685
691
  nonlocal part
686
692
  if part is None:
687
693
  raise SyntaxError(f"Cannot use {part!r} at {pos}")
@@ -1066,7 +1072,7 @@ class PathShortener:
1066
1072
  Caution: this shortener ignores path marks.
1067
1073
  """
1068
1074
 
1069
- def __init__(self, prefix: Path | list | tuple = Path()):
1075
+ def __init__(self, prefix: Path | list | tuple = Path()) -> None:
1070
1076
  self.prefix = prefix if isinstance(prefix, Path) else Path.build(prefix)
1071
1077
  self.depth = len(prefix)
1072
1078
  self.path = []
@@ -1113,7 +1119,7 @@ class PathLongener:
1113
1119
 
1114
1120
  cls: type[Path] = Path
1115
1121
 
1116
- def __init__(self, prefix: Path | PathTuple = ()):
1122
+ def __init__(self, prefix: Path | PathTuple = ()) -> None:
1117
1123
  if isinstance(prefix, Path):
1118
1124
  self.cls = type(prefix)
1119
1125
  prefix = prefix.raw
@@ -1181,7 +1187,7 @@ class Var:
1181
1187
  This mimics a ContextVar but without the context.
1182
1188
  """
1183
1189
 
1184
- def __init__(self, name, default=NotGiven):
1190
+ def __init__(self, name, default=NotGiven) -> None:
1185
1191
  self.name = name
1186
1192
  self.default = default
1187
1193
  self.data = NotGiven
@@ -1221,11 +1227,11 @@ class Var:
1221
1227
  self.data = val
1222
1228
  return _VAR_SET_TOKEN
1223
1229
 
1224
- def __bool__(self):
1230
+ def __bool__(self) -> bool:
1225
1231
  "check if value is set"
1226
1232
  return self.data is not NotGiven
1227
1233
 
1228
- def reset(self, token):
1234
+ def reset(self, token) -> None:
1229
1235
  "reset value; no-op"
1230
1236
  if token is not _VAR_SET_TOKEN:
1231
1237
  raise ValueError(token)
@@ -1244,11 +1250,11 @@ class RootPath(Path):
1244
1250
 
1245
1251
  _mark = ""
1246
1252
 
1247
- def __init__(self, key: str, var: ContextVar[Path | None] | Var):
1253
+ def __init__(self, key: str, var: ContextVar[Path | None] | Var) -> None:
1248
1254
  self._key = key
1249
1255
  self._var = var
1250
1256
 
1251
- def __repr__(self):
1257
+ def __repr__(self) -> str:
1252
1258
  return f"{self._key}={super().__repr__()}"
1253
1259
 
1254
1260
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moat-lib-path
3
- Version: 0.3.5
3
+ Version: 0.3.7
4
4
  Summary: Hierarchical path representation and manipulation for MoaT
5
5
  Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Project-URL: homepage, https://m-o-a-t.org
File without changes
File without changes
File without changes
File without changes