duty 1.2.0__py3-none-any.whl → 1.3.0__py3-none-any.whl

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.
duty/debug.py CHANGED
@@ -37,6 +37,8 @@ class Environment:
37
37
  """Python interpreter name."""
38
38
  interpreter_version: str
39
39
  """Python interpreter version."""
40
+ interpreter_path: str
41
+ """Path to Python executable."""
40
42
  platform: str
41
43
  """Operating System."""
42
44
  packages: list[Package]
@@ -83,6 +85,7 @@ def get_debug_info() -> Environment:
83
85
  return Environment(
84
86
  interpreter_name=py_name,
85
87
  interpreter_version=py_version,
88
+ interpreter_path=sys.executable,
86
89
  platform=platform.platform(),
87
90
  variables=[Variable(var, val) for var in variables if (val := os.getenv(var))],
88
91
  packages=[Package(pkg, get_version(pkg)) for pkg in packages],
@@ -93,7 +96,7 @@ def print_debug_info() -> None:
93
96
  """Print debug/environment information."""
94
97
  info = get_debug_info()
95
98
  print(f"- __System__: {info.platform}")
96
- print(f"- __Python__: {info.interpreter_name} {info.interpreter_version}")
99
+ print(f"- __Python__: {info.interpreter_name} {info.interpreter_version} ({info.interpreter_path})")
97
100
  print("- __Environment variables__:")
98
101
  for var in info.variables:
99
102
  print(f" - `{var.name}`: `{var.value}`")
duty/validation.py CHANGED
@@ -9,9 +9,21 @@ from __future__ import annotations
9
9
 
10
10
  import sys
11
11
  import textwrap
12
+ from contextlib import suppress
12
13
  from functools import cached_property
13
14
  from inspect import Parameter, Signature, signature
14
- from typing import Any, Callable, Sequence
15
+ from typing import Any, Callable, ForwardRef, Sequence, Union, get_args, get_origin
16
+
17
+ # TODO: Update once support for Python 3.9 is dropped.
18
+ if sys.version_info < (3, 10):
19
+ from eval_type_backport import eval_type_backport as eval_type
20
+
21
+ union_types = (Union,)
22
+ else:
23
+ from types import UnionType
24
+ from typing import _eval_type as eval_type # type: ignore[attr-defined]
25
+
26
+ union_types = (Union, UnionType)
15
27
 
16
28
 
17
29
  def to_bool(value: str) -> bool:
@@ -40,6 +52,12 @@ def cast_arg(arg: Any, annotation: Any) -> Any:
40
52
  return arg
41
53
  if annotation is bool:
42
54
  annotation = to_bool
55
+ if get_origin(annotation) in union_types:
56
+ for sub_annotation in get_args(annotation):
57
+ if sub_annotation is type(None):
58
+ continue
59
+ with suppress(Exception):
60
+ return cast_arg(arg, sub_annotation)
43
61
  try:
44
62
  return annotation(arg)
45
63
  except Exception: # noqa: BLE001
@@ -65,11 +83,9 @@ class ParamsCaster:
65
83
  Returns:
66
84
  The position of the variable positional parameter.
67
85
  """
68
- pos = 0
69
- for param in self.params_list:
86
+ for pos, param in enumerate(self.params_list):
70
87
  if param.kind is Parameter.VAR_POSITIONAL:
71
88
  return pos
72
- pos += 1
73
89
  return -1
74
90
 
75
91
  @cached_property
@@ -175,6 +191,7 @@ def _get_params_caster(func: Callable, *args: Any, **kwargs: Any) -> ParamsCaste
175
191
  if exec_globals[name] is annotations:
176
192
  eval_str = True
177
193
  del exec_globals[name]
194
+ break
178
195
  exec_globals["__context_above"] = {}
179
196
 
180
197
  # Don't keep first parameter: context.
@@ -188,9 +205,10 @@ def _get_params_caster(func: Callable, *args: Any, **kwargs: Any) -> ParamsCaste
188
205
  param.kind,
189
206
  default=param.default,
190
207
  annotation=(
191
- eval( # noqa: PGH001,S307
192
- param.annotation,
208
+ eval_type(
209
+ ForwardRef(param.annotation) if isinstance(param.annotation, str) else param.annotation,
193
210
  exec_globals,
211
+ {},
194
212
  )
195
213
  if param.annotation is not Parameter.empty
196
214
  else type(param.default)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: duty
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: A simple task runner.
5
- Keywords: task-runner task runner cross-platform
6
- Author-Email: Timothée Mazzucotelli <pawamoy@pm.me>
5
+ Keywords: task-runner,task,runner,cross-platform
6
+ Author-Email: =?utf-8?q?Timoth=C3=A9e_Mazzucotelli?= <dev@pawamoy.fr>
7
7
  License: ISC
8
8
  Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Intended Audience :: Developers
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
18
19
  Classifier: Topic :: Documentation
19
20
  Classifier: Topic :: Software Development
20
21
  Classifier: Topic :: Utilities
@@ -28,15 +29,16 @@ Project-URL: Discussions, https://github.com/pawamoy/duty/discussions
28
29
  Project-URL: Gitter, https://gitter.im/duty/community
29
30
  Project-URL: Funding, https://github.com/sponsors/pawamoy
30
31
  Requires-Python: >=3.8
32
+ Requires-Dist: eval-type-backport; python_version < "3.10"
31
33
  Requires-Dist: failprint!=1.0.0,>=0.11
32
34
  Description-Content-Type: text/markdown
33
35
 
34
36
  # duty
35
37
 
36
38
  [![ci](https://github.com/pawamoy/duty/workflows/ci/badge.svg)](https://github.com/pawamoy/duty/actions?query=workflow%3Aci)
37
- [![documentation](https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat)](https://pawamoy.github.io/duty/)
39
+ [![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://pawamoy.github.io/duty/)
38
40
  [![pypi version](https://img.shields.io/pypi/v/duty.svg)](https://pypi.org/project/duty/)
39
- [![gitpod](https://img.shields.io/badge/gitpod-workspace-blue.svg?style=flat)](https://gitpod.io/#https://github.com/pawamoy/duty)
41
+ [![gitpod](https://img.shields.io/badge/gitpod-workspace-708FCC.svg?style=flat)](https://gitpod.io/#https://github.com/pawamoy/duty)
40
42
  [![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#duty:gitter.im)
41
43
 
42
44
  A simple task runner.
@@ -1,7 +1,7 @@
1
- duty-1.2.0.dist-info/METADATA,sha256=tfki6IuLH8oKRFwO-ey-lyrrWbBh5oZtLn1hEunu-fI,2717
2
- duty-1.2.0.dist-info/WHEEL,sha256=N2J68yzZqJh3mI_Wg92rwhw0rtJDFpZj9bwQIMJgaVg,90
3
- duty-1.2.0.dist-info/entry_points.txt,sha256=gxDUGvj_bg7DA77MogNmnGQSc2__ri9kAEp2RJ1p60Q,40
4
- duty-1.2.0.dist-info/licenses/LICENSE,sha256=nQxdYSduhkgEpOTmg4yyIMmFPzcr2qrlUl8Tf9QZPug,754
1
+ duty-1.3.0.dist-info/METADATA,sha256=Z_a3NfoAhbBn6wUHNHWIa9oJ5-l5t3CeSeoqv247WME,2837
2
+ duty-1.3.0.dist-info/WHEEL,sha256=7sv5iXvIiTVJSnAxCz2tGBm9DHsb2vPSzeYeT7pvGUY,90
3
+ duty-1.3.0.dist-info/entry_points.txt,sha256=gxDUGvj_bg7DA77MogNmnGQSc2__ri9kAEp2RJ1p60Q,40
4
+ duty-1.3.0.dist-info/licenses/LICENSE,sha256=nQxdYSduhkgEpOTmg4yyIMmFPzcr2qrlUl8Tf9QZPug,754
5
5
  duty/__init__.py,sha256=2fdBMNEBXYSCnV1GQm56VGe8VuvMp79-Hj3SHrAb5MM,144
6
6
  duty/__main__.py,sha256=4YvloGDKmyVzOsE6ZdyCQyY0Jsl0LSlbqkO2UDExgmI,333
7
7
  duty/callables/__init__.py,sha256=U1vfn41ZtDDdje9yLwmrdcoJ8jxANARdTCvZ8paX8W0,1661
@@ -22,9 +22,9 @@ duty/callables/ssort.py,sha256=Lqak-xfJtKkj3AaI4_jPeaRkZ9SbvMCYhoUIVVHE6s8,842
22
22
  duty/cli.py,sha256=s62m0HO4PwdxutVX1P0H_a0yPN-mVOE5VYEJkRvJCRA,8436
23
23
  duty/collection.py,sha256=cri--t6aUmOw3c17yCy9tAp_ceHfEQMhf4tMqPssNa0,6590
24
24
  duty/context.py,sha256=aH1CPLnlHMnMaHc-cGTBv-xZioSLQxNIDo1xcQGuiO8,2985
25
- duty/debug.py,sha256=o-g8vpvl48STTQ3SKPNroJ3sqYvivbhmmya2zo3adQ4,2683
25
+ duty/debug.py,sha256=9stdqxNJ9zA2HWsYfmy3C9BrWOXLlHYRGsQ6dHfCUfM,2813
26
26
  duty/decorator.py,sha256=1IVYNOeVhLv4OkFtXAXcFKyy8xypfQBh3WM8aJLKohU,2986
27
27
  duty/exceptions.py,sha256=gTtqtqOiMroP5-83kC5jakuwBfYKpzCQHE9RWfAGRv0,358
28
28
  duty/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- duty/validation.py,sha256=f_H3KNWNtGgkPQSU18Q5esX3A2af6t2m_I_PnqkggOI,7305
30
- duty-1.2.0.dist-info/RECORD,,
29
+ duty/validation.py,sha256=1teu9-04anIShuOeWVcqhXLfvWOFKTSRdrclsGMZxdU,8052
30
+ duty-1.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.1.8)
2
+ Generator: pdm-backend (2.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any