preparse 1.0.13.post1.dev1__tar.gz → 1.0.13.post2__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 (40) hide show
  1. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/PKG-INFO +1 -1
  2. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/pyproject.toml +1 -1
  3. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/Bundle.py +10 -10
  4. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/Item.py +2 -2
  5. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/Long.py +9 -10
  6. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/Option.py +7 -7
  7. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/Positional.py +2 -3
  8. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/Special.py +0 -1
  9. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_processing/__init__.py +4 -3
  10. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_processing/digesting.py +6 -13
  11. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_processing/parsing.py +10 -17
  12. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/core/Click.py +3 -3
  13. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/core/Optdict.py +22 -16
  14. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/core/PreParser.py +10 -29
  15. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/core/warnings.py +30 -33
  16. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/test_data_toml.py +3 -14
  17. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/test_expit_toml.py +5 -15
  18. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/test_optdict.py +0 -8
  19. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse.egg-info/PKG-INFO +1 -1
  20. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/LICENSE.txt +0 -0
  21. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/MANIFEST.in +0 -0
  22. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/README.rst +0 -0
  23. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/docs/v1.0.rst +0 -0
  24. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/setup.cfg +0 -0
  25. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/__init__.py +0 -0
  26. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_items/__init__.py +0 -0
  27. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_processing/deparsing.py +0 -0
  28. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/_processing/pulling.py +0 -0
  29. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/core/__init__.py +0 -0
  30. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/core/enums.py +0 -0
  31. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/py.typed +0 -0
  32. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/__init__.py +0 -0
  33. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/data.toml +0 -0
  34. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/expit.toml +0 -0
  35. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/test_enums.py +0 -0
  36. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse/tests/test_preparser.py +0 -0
  37. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse.egg-info/SOURCES.txt +0 -0
  38. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse.egg-info/dependency_links.txt +0 -0
  39. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse.egg-info/requires.txt +0 -0
  40. {preparse-1.0.13.post1.dev1 → preparse-1.0.13.post2}/src/preparse.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: preparse
3
- Version: 1.0.13.post1.dev1
3
+ Version: 1.0.13.post2
4
4
  Summary: This project preparses args for further parsing later on.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License-Expression: MIT
@@ -37,7 +37,7 @@ license-files = [
37
37
  name = "preparse"
38
38
  readme = "README.rst"
39
39
  requires-python = ">=3.11"
40
- version = "1.0.13.post1.dev1"
40
+ version = "1.0.13.post2"
41
41
 
42
42
  [project.urls]
43
43
  Download = "https://pypi.org/project/preparse/#files"
@@ -1,20 +1,20 @@
1
+ from __future__ import annotations
2
+
1
3
  __all__: list[str] = ["Bundle"]
2
4
 
3
5
  from typing import Any, Self
4
6
 
5
7
  import setdoc
6
8
 
7
- from preparse._items.Item import Item
8
9
  from preparse._items.Option import Option
9
- from preparse.core.enums import Nargs, Tuning
10
10
 
11
11
 
12
12
  class Bundle(Option):
13
13
 
14
- chars: str
15
- joined: bool
16
- nargs: Nargs
17
- right: str | None
14
+ # chars: str
15
+ # joined: bool
16
+ # nargs: Nargs
17
+ # right: str | None
18
18
 
19
19
  __slots__ = ()
20
20
 
@@ -37,7 +37,7 @@ class Bundle(Option):
37
37
  ans = list()
38
38
  for x in chars:
39
39
  if x == "-":
40
- ans[-1].chars += "-"
40
+ ans[-1] += "-"
41
41
  else:
42
42
  ans.append(x)
43
43
  return ans
@@ -62,7 +62,7 @@ class Bundle(Option):
62
62
 
63
63
  @property
64
64
  def chars(self: Self) -> str:
65
- return self._data["chars"]
65
+ return self._data["chars"] # type: ignore[no-any-return]
66
66
 
67
67
  @chars.setter
68
68
  def chars(self: Self, x: Any) -> None:
@@ -77,8 +77,8 @@ class Bundle(Option):
77
77
  else:
78
78
  return ["-" + self.chars, self.right]
79
79
 
80
- def split(self: Self, *, allowslong: bool) -> list[Item]:
81
- ans: list[Self]
80
+ def split(self: Self, *, allowslong: bool) -> list[Bundle]:
81
+ ans: list[Bundle]
82
82
  parts: list[str]
83
83
  x: str
84
84
  if allowslong:
@@ -6,12 +6,12 @@ from typing import Any, Self
6
6
  import setdoc
7
7
  from copyable import Copyable
8
8
 
9
- from preparse.core.enums import Nargs, Tuning
10
-
11
9
 
12
10
  class Item(Copyable):
13
11
  __slots__ = ("_data",)
14
12
 
13
+ _data: dict[str, Any]
14
+
15
15
  @setdoc.basic
16
16
  def copy(self: Self) -> Self:
17
17
  return type(self)(**self.todict())
@@ -6,17 +6,16 @@ from typing import Any, Self, SupportsIndex
6
6
  import setdoc
7
7
 
8
8
  from preparse._items.Option import Option
9
- from preparse.core.enums import Nargs, Tuning
10
9
 
11
10
 
12
11
  class Long(Option):
13
12
 
14
- abbr: str
15
- abbrlen: int | None
16
- fullkey: str
17
- joined: bool
18
- nargs: Nargs
19
- right: str | None
13
+ # abbr: str
14
+ # abbrlen: int | None
15
+ # fullkey: str
16
+ # joined: bool
17
+ # nargs: Nargs
18
+ # right: str | None
20
19
 
21
20
  __slots__ = ()
22
21
 
@@ -26,7 +25,7 @@ class Long(Option):
26
25
  *,
27
26
  abbrlen: int | None = None,
28
27
  fullkey: str,
29
- joined: bool | str = False,
28
+ joined: bool = False,
30
29
  right: str | None = None,
31
30
  ) -> None:
32
31
  self.fullkey = fullkey
@@ -40,7 +39,7 @@ class Long(Option):
40
39
 
41
40
  @property
42
41
  def abbrlen(self: Self) -> int | None:
43
- return self._data["abbrlen"]
42
+ return self._data["abbrlen"] # type: ignore[no-any-return]
44
43
 
45
44
  @abbrlen.setter
46
45
  def abbrlen(self: Self, x: SupportsIndex | None) -> None:
@@ -60,7 +59,7 @@ class Long(Option):
60
59
 
61
60
  @property
62
61
  def fullkey(self: Self) -> str:
63
- return self._data["fullkey"]
62
+ return self._data["fullkey"] # type: ignore[no-any-return]
64
63
 
65
64
  @fullkey.setter
66
65
  def fullkey(self: Self, x: Any) -> None:
@@ -4,14 +4,14 @@ import operator
4
4
  from typing import Any, Self, SupportsIndex
5
5
 
6
6
  from preparse._items.Item import Item
7
- from preparse.core.enums import Nargs, Tuning
7
+ from preparse.core.enums import Nargs
8
8
 
9
9
 
10
10
  class Option(Item):
11
11
 
12
- joined: bool
13
- nargs: Nargs
14
- right: str | None
12
+ # joined: bool
13
+ # nargs: Nargs
14
+ # right: str | None
15
15
 
16
16
  __slots__ = ()
17
17
 
@@ -20,7 +20,7 @@ class Option(Item):
20
20
 
21
21
  @property
22
22
  def joined(self: Self) -> bool:
23
- return self._data["joined"]
23
+ return self._data["joined"] # type: ignore[no-any-return]
24
24
 
25
25
  @joined.setter
26
26
  def joined(self: Self, x: SupportsIndex) -> None:
@@ -29,7 +29,7 @@ class Option(Item):
29
29
 
30
30
  @property
31
31
  def nargs(self: Self) -> Nargs:
32
- return self._data["nargs"]
32
+ return self._data["nargs"] # type: ignore[no-any-return]
33
33
 
34
34
  @nargs.setter
35
35
  def nargs(self: Self, x: Any) -> None:
@@ -38,7 +38,7 @@ class Option(Item):
38
38
 
39
39
  @property
40
40
  def right(self: Self) -> str | None:
41
- return self._data["right"]
41
+ return self._data["right"] # type: ignore[no-any-return]
42
42
 
43
43
  @right.setter
44
44
  def right(self: Self, x: Any) -> None:
@@ -5,12 +5,11 @@ from typing import Any, Self
5
5
  import setdoc
6
6
 
7
7
  from preparse._items.Item import Item
8
- from preparse.core.enums import Nargs, Tuning
9
8
 
10
9
 
11
10
  class Positional(Item):
12
11
 
13
- value: str
12
+ # value: str
14
13
 
15
14
  __slots__ = ()
16
15
 
@@ -30,7 +29,7 @@ class Positional(Item):
30
29
 
31
30
  @property
32
31
  def value(self: Self) -> str:
33
- return self._data["value"]
32
+ return self._data["value"] # type: ignore[no-any-return]
34
33
 
35
34
  @value.setter
36
35
  def value(self: Self, x: Any) -> None:
@@ -3,7 +3,6 @@ __all__: list[str] = ["Special"]
3
3
  from typing import Self
4
4
 
5
5
  from preparse._items.Item import Item
6
- from preparse.core.enums import Nargs, Tuning
7
6
 
8
7
 
9
8
  class Special(Item):
@@ -4,7 +4,7 @@ from collections.abc import Iterable
4
4
  from types import FunctionType
5
5
  from typing import Any
6
6
 
7
- from preparse._items import Bundle, Item, Long, Option, Positional, Special
7
+ from preparse._items import Item, Positional
8
8
  from preparse._processing.deparsing import deparse
9
9
  from preparse._processing.digesting import digest
10
10
  from preparse._processing.parsing import parse
@@ -29,9 +29,10 @@ def process(
29
29
  ) -> list[str]:
30
30
  "This method parses args."
31
31
  items: list[Item]
32
- items = pull(args)
32
+ positionals: list[Positional]
33
+ positionals = pull(args)
33
34
  items = parse(
34
- items,
35
+ positionals,
35
36
  allowslong=allowslong,
36
37
  allowsshort=allowsshort,
37
38
  expectsabbr=expectsabbr,
@@ -8,14 +8,7 @@ from preparse._items.Long import Long
8
8
  from preparse._items.Option import Option
9
9
  from preparse._items.Positional import Positional
10
10
  from preparse._items.Special import Special
11
- from preparse.core.enums import Nargs, Tuning
12
- from preparse.core.warnings import (
13
- PreparseAmbiguousOptionWarning,
14
- PreparseInvalidOptionWarning,
15
- PreparseRequiredArgumentWarning,
16
- PreparseUnallowedArgumentWarning,
17
- PreparseWarning,
18
- )
11
+ from preparse.core.enums import Tuning
19
12
 
20
13
 
21
14
  def digest(
@@ -146,7 +139,7 @@ def digest_order(
146
139
  if isinstance(ans[index], Special):
147
140
  comp = True
148
141
  break
149
- if not ans[index].isobvious():
142
+ if not ans[index].isobvious(): # type: ignore[attr-defined]
150
143
  comp = False
151
144
  if not comp:
152
145
  ans.insert(index + 1, Special())
@@ -183,9 +176,9 @@ def digest_special_max(items: list[Item]) -> list[Item]:
183
176
  break
184
177
  if isinstance(ans[index], Positional):
185
178
  continue
186
- if ans[index].ishungry():
187
- ans[index].joined = False
188
- ans[index].right = "--"
179
+ if ans[index].ishungry(): # type: ignore[attr-defined]
180
+ ans[index].joined = False # type: ignore[attr-defined]
181
+ ans[index].right = "--" # type: ignore[attr-defined]
189
182
  ans.insert(index + 1, Special())
190
183
  break
191
184
  return ans
@@ -215,7 +208,7 @@ def digest_special_min(
215
208
  break
216
209
  if isinstance(ans[index], Special):
217
210
  break
218
- isdel = ans[index].isobvious()
211
+ isdel = ans[index].isobvious() # type: ignore[attr-defined]
219
212
  if not (isdel or isposix):
220
213
  break
221
214
  if isdel:
@@ -10,21 +10,14 @@ from preparse._items.Long import Long
10
10
  from preparse._items.Option import Option
11
11
  from preparse._items.Positional import Positional
12
12
  from preparse._items.Special import Special
13
- from preparse.core import warnings
14
- from preparse.core.enums import Nargs, Tuning
13
+ from preparse.core.enums import Nargs
14
+ from preparse.core.warnings import PreparseAmbiguousOptionWarning as PAOW
15
+ from preparse.core.warnings import PreparseInvalidOptionWarning as PIOW
16
+ from preparse.core.warnings import PreparseRequiredArgumentWarning as PRAW
17
+ from preparse.core.warnings import PreparseUnallowedArgumentWarning as PUAW
15
18
 
16
- PAOW: type[Any]
17
- PIOW: type[Any]
18
- PRAW: type[Any]
19
- PUAW: type[Any]
20
19
 
21
- PAOW = warnings.PreparseAmbiguousOptionWarning
22
- PIOW = warnings.PreparseInvalidOptionWarning
23
- PUAW = warnings.PreparseUnallowedArgumentWarning
24
- PRAW = warnings.PreparseRequiredArgumentWarning
25
-
26
-
27
- def parse(args: list[str], **kwargs: Any) -> list[Item]:
20
+ def parse(args: list[Positional], **kwargs: Any) -> list[Item]:
28
21
  return list(parse_generator(args, **kwargs))
29
22
 
30
23
 
@@ -64,7 +57,7 @@ def parse_cause(
64
57
  def ans(cls: type[Any], **kwargs: Any) -> None:
65
58
  warn(cls(prog=prog, **kwargs))
66
59
 
67
- return ans
60
+ return ans # type: ignore[return-value]
68
61
 
69
62
 
70
63
  def parse_generator(
@@ -77,11 +70,11 @@ def parse_generator(
77
70
  optdict: dict[str, Nargs],
78
71
  prog: str,
79
72
  warn: FunctionType,
80
- ) -> Generator[Any, Any, Any]:
73
+ ) -> Generator[Item, None, None]:
81
74
  broken: bool
82
75
  cause: FunctionType
83
76
  item: Positional
84
- last: Option | None
77
+ last: Long | Bundle | None
85
78
  broken = not (allowslong or allowsshort)
86
79
  cause = parse_cause(prog=prog, warn=warn)
87
80
  last = None
@@ -196,7 +189,7 @@ def parse_option(
196
189
  expectsabbr: bool,
197
190
  optdict: dict[str, Nargs],
198
191
  **kwargs: Any,
199
- ) -> Option:
192
+ ) -> Bundle | Long:
200
193
  if parse_islong(arg, **kwargs):
201
194
  return parse_long(
202
195
  arg,
@@ -32,7 +32,7 @@ class Click(Copyable):
32
32
  return "method"
33
33
  return "other"
34
34
 
35
- @__call__.overload("function")
35
+ @__call__.overload("function") # type: ignore[no-redef]
36
36
  def __call__(self: Self, target: types.FunctionType) -> types.FunctionType:
37
37
  @functools.wraps(target)
38
38
  def ans(cmd: Any, ctx: Any, args: Any) -> Any:
@@ -46,13 +46,13 @@ class Click(Copyable):
46
46
 
47
47
  return ans
48
48
 
49
- @__call__.overload("method")
49
+ @__call__.overload("method") # type: ignore[no-redef]
50
50
  def __call__(self: Self, target: types.MethodType) -> types.MethodType:
51
51
  func: Callable[..., Any]
52
52
  func = self(target.__func__)
53
53
  return types.MethodType(func, target.__self__)
54
54
 
55
- @__call__.overload("other")
55
+ @__call__.overload("other") # type: ignore[no-redef]
56
56
  def __call__(self: Self, target: Any) -> Any:
57
57
  target.parse_args = self(target.parse_args)
58
58
  return target
@@ -1,47 +1,53 @@
1
1
  __all__: list[str] = ["Optdict"]
2
2
 
3
- from collections.abc import Iterator
4
- from typing import Any, Self
3
+ from collections.abc import Iterable, Iterator
4
+ from typing import Any, Self, overload
5
5
 
6
6
  import cmp3
7
7
  import datahold
8
+ import datahold.typing
8
9
  import setdoc
9
10
  from datarepr import datarepr
10
11
  from frozendict import frozendict
11
12
 
12
- from preparse.core.enums import Nargs, Tuning
13
- from preparse.core.warnings import (
14
- PreparseAmbiguousOptionWarning,
15
- PreparseInvalidOptionWarning,
16
- PreparseRequiredArgumentWarning,
17
- PreparseUnallowedArgumentWarning,
18
- PreparseWarning,
19
- )
13
+ from preparse.core.enums import Nargs
20
14
 
21
15
 
22
16
  class Optdict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
23
17
  __slots__ = ()
24
18
 
25
- data: frozendict[str, Nargs]
26
-
27
19
  @setdoc.basic
28
20
  def __cmp__(self: Self, other: Any, /) -> int | None:
29
21
  if type(self) is type(other):
30
- return cmp3.cmp(self._data, other._data, mode="eq_strict")
22
+ return cmp3.cmp(self._data, other._data, mode="eq_strict") # type: ignore[no-any-return]
31
23
  else:
32
- return cmp3.cmp(self._data, other, mode="eq_strict")
24
+ return cmp3.cmp(self._data, other, mode="eq_strict") # type: ignore[no-any-return]
33
25
 
34
26
  __format__ = object.__format__
35
27
 
28
+ @setdoc.basic
29
+ def __init__(
30
+ self: Self,
31
+ other: (
32
+ datahold.typing.SupportsKeysAndGetitem.SupportsKeysAndGetitem[
33
+ object, object
34
+ ]
35
+ | Iterable[tuple[object, object]]
36
+ ) = (),
37
+ /,
38
+ **kwargs: object,
39
+ ) -> None:
40
+ datahold.HoldDict.__init__(self, other, **kwargs)
41
+
36
42
  @setdoc.basic
37
43
  def __repr__(self: Self, /) -> str:
38
44
  return datarepr(type(self).__name__, dict(self._data))
39
45
 
40
46
  __str__ = object.__str__
41
47
 
42
- @property
48
+ @property # type: ignore[override]
43
49
  def data(self: Self) -> frozendict[str, Nargs]:
44
- return frozendict[str, Nargs](self._data)
50
+ return frozendict[str, Nargs](self._data) # type: ignore[arg-type]
45
51
 
46
52
  @data.setter
47
53
  def data(self: Self, value: Any) -> None:
@@ -18,29 +18,10 @@ from preparse._processing import process
18
18
  from preparse.core.Click import Click
19
19
  from preparse.core.enums import Nargs, Tuning
20
20
  from preparse.core.Optdict import Optdict
21
- from preparse.core.warnings import (
22
- PreparseAmbiguousOptionWarning,
23
- PreparseInvalidOptionWarning,
24
- PreparseRequiredArgumentWarning,
25
- PreparseUnallowedArgumentWarning,
26
- PreparseWarning,
27
- )
28
21
 
29
22
 
30
23
  class PreParser(Copyable):
31
24
 
32
- allowslong: bool
33
- allowsshort: bool
34
- bundling: Tuning
35
- expandsabbr: bool
36
- expectsabbr: bool
37
- expectsposix: bool
38
- optdict: Optdict
39
- prog: str
40
- reconcilesorders: bool
41
- special: Tuning
42
- warn: types.FunctionType
43
-
44
25
  __slots__ = ("_data",)
45
26
 
46
27
  @setdoc.basic
@@ -86,7 +67,7 @@ class PreParser(Copyable):
86
67
 
87
68
  @property
88
69
  def allowsshort(self: Self) -> bool:
89
- return self._data["allowsshort"]
70
+ return self._data["allowsshort"] # type: ignore[no-any-return]
90
71
 
91
72
  @allowsshort.setter
92
73
  def allowsshort(self: Self, value: Any) -> None:
@@ -96,7 +77,7 @@ class PreParser(Copyable):
96
77
  @property
97
78
  def bundling(self: Self) -> Tuning:
98
79
  "This property decides how to approach the bundling of short options."
99
- return self._data["bundling"]
80
+ return self._data["bundling"] # type: ignore[no-any-return]
100
81
 
101
82
  @bundling.setter
102
83
  def bundling(self: Self, value: Any) -> None:
@@ -113,7 +94,7 @@ class PreParser(Copyable):
113
94
 
114
95
  @property
115
96
  def expandsabbr(self: Self) -> bool:
116
- return self._data["expandsabbr"]
97
+ return self._data["expandsabbr"] # type: ignore[no-any-return]
117
98
 
118
99
  @expandsabbr.setter
119
100
  def expandsabbr(self: Self, value: Any) -> None:
@@ -122,7 +103,7 @@ class PreParser(Copyable):
122
103
 
123
104
  @property
124
105
  def expectsabbr(self: Self) -> bool:
125
- return self._data["expectsabbr"]
106
+ return self._data["expectsabbr"] # type: ignore[no-any-return]
126
107
 
127
108
  @expectsabbr.setter
128
109
  def expectsabbr(self: Self, value: Any) -> None:
@@ -131,7 +112,7 @@ class PreParser(Copyable):
131
112
 
132
113
  @property
133
114
  def expectsposix(self: Self) -> bool:
134
- return self._data["expectsposix"]
115
+ return self._data["expectsposix"] # type: ignore[no-any-return]
135
116
 
136
117
  @expectsposix.setter
137
118
  def expectsposix(self: Self, value: Any) -> None:
@@ -146,7 +127,7 @@ class PreParser(Copyable):
146
127
  @property
147
128
  def optdict(self: Self) -> Optdict:
148
129
  "This property gives a dictionary of options."
149
- return self._data["optdict"]
130
+ return self._data["optdict"] # type: ignore[no-any-return]
150
131
 
151
132
  @optdict.setter
152
133
  def optdict(self: Self, value: Any) -> None:
@@ -169,7 +150,7 @@ class PreParser(Copyable):
169
150
  @property
170
151
  def prog(self: Self) -> str:
171
152
  "This property represents the name of the program."
172
- return self._data["prog"]
153
+ return self._data["prog"] # type: ignore[no-any-return]
173
154
 
174
155
  @prog.setter
175
156
  def prog(self: Self, value: Any) -> None:
@@ -181,7 +162,7 @@ class PreParser(Copyable):
181
162
 
182
163
  @property
183
164
  def reconcilesorders(self: Self) -> bool:
184
- return self._data["reconcilesorders"]
165
+ return self._data["reconcilesorders"] # type: ignore[no-any-return]
185
166
 
186
167
  @reconcilesorders.setter
187
168
  def reconcilesorders(self: Self, value: Any) -> None:
@@ -216,7 +197,7 @@ class PreParser(Copyable):
216
197
  @property
217
198
  def special(self: Self) -> Tuning:
218
199
  "This Tuning property determines the approach towards the special argument."
219
- return self._data["special"]
200
+ return self._data["special"] # type: ignore[no-any-return]
220
201
 
221
202
  @special.setter
222
203
  def special(self: Self, value: Any) -> None:
@@ -237,7 +218,7 @@ class PreParser(Copyable):
237
218
  @property
238
219
  def warn(self: Self) -> types.FunctionType:
239
220
  "This property gives a function that takes in the warnings."
240
- return self._data["warn"]
221
+ return self._data["warn"] # type: ignore[no-any-return]
241
222
 
242
223
  @warn.setter
243
224
  def warn(self: Self, value: Callable[..., Any]) -> None:
@@ -16,9 +16,6 @@ from datarepr import datarepr
16
16
 
17
17
 
18
18
  class PreparseWarning(Warning, Copyable):
19
- args: tuple[str]
20
- option: str
21
- prog: str
22
19
 
23
20
  @setdoc.basic
24
21
  def __repr__(self: Self) -> str:
@@ -29,7 +26,7 @@ class PreparseWarning(Warning, Copyable):
29
26
  return f"{self.prog}: {self.getmsg()}"
30
27
 
31
28
  @property
32
- def args(self: Self) -> tuple[str]:
29
+ def args(self: Self) -> tuple[str]: # type: ignore[override]
33
30
  "This property returns (str(self),)."
34
31
  return (str(self),)
35
32
 
@@ -51,7 +48,7 @@ class PreparseWarning(Warning, Copyable):
51
48
 
52
49
  @property
53
50
  def prog(self: Self) -> str:
54
- return self._data["prog"]
51
+ return self._data["prog"] # type: ignore[no-any-return]
55
52
 
56
53
  @prog.setter
57
54
  def prog(self: Self, value: Any) -> None:
@@ -72,26 +69,29 @@ class PreparseWarning(Warning, Copyable):
72
69
 
73
70
  class PreparseDualWarning(PreparseWarning):
74
71
 
75
- args: tuple[str]
76
- option: str
77
- prog: str
78
-
79
72
  @setdoc.basic
80
73
  def __init__(self: Self, *, islong: Any, option: Any, prog: Any) -> None:
81
74
  self.prog = prog
82
75
  self.option = option
83
76
  self.islong = islong
84
77
 
78
+ @staticmethod
79
+ @abstractmethod
80
+ def _longmsg() -> str: ...
81
+ @staticmethod
82
+ @abstractmethod
83
+ def _shortmsg() -> str: ...
84
+
85
85
  def getmsg(self: Self) -> str:
86
86
  "This method returns the core message."
87
87
  if self.islong:
88
- return type(self)._longmsg % self.option
88
+ return self._longmsg() % self.option
89
89
  else:
90
- return type(self)._shortmsg % self.option
90
+ return self._shortmsg() % self.option
91
91
 
92
92
  @property
93
93
  def islong(self: Self) -> bool:
94
- return self._data["islong"]
94
+ return self._data["islong"] # type: ignore[no-any-return]
95
95
 
96
96
  @islong.setter
97
97
  def islong(self: Self, value: Any) -> None:
@@ -100,33 +100,32 @@ class PreparseDualWarning(PreparseWarning):
100
100
 
101
101
 
102
102
  class PreparseInvalidOptionWarning(PreparseDualWarning):
103
- args: tuple[str]
104
- option: str
105
- prog: str
106
- _longmsg = "unrecognized option '%s'"
107
- _shortmsg = "invalid option -- '%s'"
103
+ @staticmethod
104
+ def _longmsg() -> str:
105
+ return "unrecognized option '%s'"
106
+
107
+ @staticmethod
108
+ def _shortmsg() -> str:
109
+ return "invalid option -- '%s'"
108
110
 
109
111
 
110
112
  class PreparseRequiredArgumentWarning(PreparseDualWarning):
111
- args: tuple[str]
112
- option: str
113
- prog: str
114
- _longmsg = "option '%s' requires an argument"
115
- _shortmsg = "option requires an argument -- '%s'"
113
+
114
+ @staticmethod
115
+ def _longmsg() -> str:
116
+ return "option '%s' requires an argument"
117
+
118
+ @staticmethod
119
+ def _shortmsg() -> str:
120
+ return "option requires an argument -- '%s'"
116
121
 
117
122
 
118
123
  class PreparseLongonlyWarning(PreparseWarning):
119
- args: tuple[str]
120
- option: str
121
- prog: str
124
+ pass
122
125
  # only possible for long options
123
126
 
124
127
 
125
128
  class PreparseAmbiguousOptionWarning(PreparseLongonlyWarning):
126
- args: tuple[str]
127
- option: str
128
- possibilities: tuple[str, ...]
129
- prog: str
130
129
 
131
130
  @setdoc.basic
132
131
  def __init__(
@@ -147,7 +146,7 @@ class PreparseAmbiguousOptionWarning(PreparseLongonlyWarning):
147
146
 
148
147
  @property
149
148
  def possibilities(self: Self) -> tuple[str, ...]:
150
- return self._data["possibilities"]
149
+ return self._data["possibilities"] # type: ignore[no-any-return]
151
150
 
152
151
  @possibilities.setter
153
152
  def possibilities(self: Self, value: Iterable[Any]) -> None:
@@ -156,9 +155,7 @@ class PreparseAmbiguousOptionWarning(PreparseLongonlyWarning):
156
155
 
157
156
 
158
157
  class PreparseUnallowedArgumentWarning(PreparseLongonlyWarning):
159
- args: tuple[str]
160
- option: str
161
- prog: str
158
+
162
159
  # option is always full key without value
163
160
 
164
161
  @setdoc.basic
@@ -6,23 +6,11 @@ import unittest
6
6
  from importlib import resources
7
7
  from typing import Any, Self
8
8
 
9
- from preparse.core import (
10
- Click,
11
- Nargs,
12
- Optdict,
13
- PreparseAmbiguousOptionWarning,
14
- PreparseInvalidOptionWarning,
15
- PreParser,
16
- PreparseRequiredArgumentWarning,
17
- PreparseUnallowedArgumentWarning,
18
- PreparseWarning,
19
- Tuning,
20
- enums,
21
- warnings,
22
- )
9
+ from preparse.core import PreParser
23
10
 
24
11
 
25
12
  class utils:
13
+ @staticmethod
26
14
  def get_data() -> dict[str, Any]:
27
15
  data: dict[str, Any]
28
16
  text: str
@@ -30,6 +18,7 @@ class utils:
30
18
  data = tomllib.loads(text)
31
19
  return data
32
20
 
21
+ @staticmethod
33
22
  def istestable(x: Any) -> bool:
34
23
  if not isinstance(x, float):
35
24
  return True
@@ -9,24 +9,12 @@ from typing import Any, Self
9
9
  import click
10
10
  from click.testing import CliRunner
11
11
 
12
- from preparse.core import (
13
- Click,
14
- Nargs,
15
- Optdict,
16
- PreparseAmbiguousOptionWarning,
17
- PreparseInvalidOptionWarning,
18
- PreParser,
19
- PreparseRequiredArgumentWarning,
20
- PreparseUnallowedArgumentWarning,
21
- PreparseWarning,
22
- Tuning,
23
- enums,
24
- warnings,
25
- )
12
+ from preparse.core import PreParser
26
13
 
27
14
 
28
15
  class expit:
29
16
 
17
+ @staticmethod
30
18
  def function(x: float) -> float:
31
19
  p: float
32
20
  try:
@@ -35,7 +23,7 @@ class expit:
35
23
  p = float("+inf")
36
24
  return 1 / (1 + p)
37
25
 
38
- @PreParser(reconcilesorders=True, expectsposix=False).click()
26
+ @PreParser(reconcilesorders=True, expectsposix=False).click() # type: ignore
39
27
  @click.command(add_help_option=False)
40
28
  @click.help_option("-h", "--help")
41
29
  @click.version_option("1.2.3", "-V", "--version")
@@ -46,6 +34,7 @@ class expit:
46
34
 
47
35
 
48
36
  class utils:
37
+ @staticmethod
49
38
  def get_data() -> dict[str, Any]:
50
39
  data: dict[str, Any]
51
40
  text: str
@@ -53,6 +42,7 @@ class utils:
53
42
  data = tomllib.loads(text)
54
43
  return data
55
44
 
45
+ @staticmethod
56
46
  def istestable(x: Any) -> bool:
57
47
  if not isinstance(x, float):
58
48
  return True
@@ -3,15 +3,7 @@ __all__: list[str] = ["TestPreparse"]
3
3
  import unittest
4
4
  from typing import Self
5
5
 
6
- from preparse.core.enums import Nargs, Tuning
7
6
  from preparse.core.Optdict import Optdict
8
- from preparse.core.warnings import (
9
- PreparseAmbiguousOptionWarning,
10
- PreparseInvalidOptionWarning,
11
- PreparseRequiredArgumentWarning,
12
- PreparseUnallowedArgumentWarning,
13
- PreparseWarning,
14
- )
15
7
 
16
8
 
17
9
  class TestPreparse(unittest.TestCase):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: preparse
3
- Version: 1.0.13.post1.dev1
3
+ Version: 1.0.13.post2
4
4
  Summary: This project preparses args for further parsing later on.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License-Expression: MIT