Skip to content

Commit c686837

Browse files
authored
Typehint wrapping (#1436)
fixed type hints in function wrapper
1 parent 3fa23e8 commit c686837

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Other contributors, listed alphabetically, are:
4545
* Ryan Dwyer <[email protected]>
4646
* Ryan Kingsbury <[email protected]>
4747
* Ryan May
48+
* Sebastian Kosmeier
4849
* Sigvald Marholm <[email protected]>
4950
* Sundar Raman <[email protected]>
5051
* Tiago Coutinho <[email protected]>

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Pint Changelog
44
0.19 (unreleased)
55
-----------------
66

7+
- Fix type hints of function wrapper (Issue #1431)
78
- Upgrade min version of uncertainties to 3.1.4
89
- Fix setting options of the application registry (Issue #1403).
910
- Fix Quantity & Unit `is_compatible_with` with registry active contexts (Issue #1424).

pint/registry_helpers.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def _apply_defaults(func, args, kwargs):
186186

187187
def wraps(
188188
ureg: "UnitRegistry",
189-
ret: Union[str, "Unit", Iterable[str], Iterable["Unit"], None],
190-
args: Union[str, "Unit", Iterable[str], Iterable["Unit"], None],
189+
ret: Union[str, "Unit", Iterable[Union[str, "Unit", None]], None],
190+
args: Union[str, "Unit", Iterable[Union[str, "Unit", None]], None],
191191
strict: bool = True,
192192
) -> Callable[[Callable[..., T]], Callable[..., Quantity[T]]]:
193193
"""Wraps a function to become pint-aware.
@@ -204,9 +204,9 @@ def wraps(
204204
----------
205205
ureg : pint.UnitRegistry
206206
a UnitRegistry instance.
207-
ret : str, pint.Unit, iterable of str, or iterable of pint.Unit
207+
ret : str, pint.Unit, or iterable of str or pint.Unit
208208
Units of each of the return values. Use `None` to skip argument conversion.
209-
args : str, pint.Unit, iterable of str, or iterable of pint.Unit
209+
args : str, pint.Unit, or iterable of str or pint.Unit
210210
Units of each of the input arguments. Use `None` to skip argument conversion.
211211
strict : bool
212212
Indicates that only quantities are accepted. (Default value = True)
@@ -220,7 +220,7 @@ def wraps(
220220
------
221221
TypeError
222222
if the number of given arguments does not match the number of function parameters.
223-
if the any of the provided arguments is not a unit a string or Quantity
223+
if any of the provided arguments is not a unit a string or Quantity
224224
225225
"""
226226

0 commit comments

Comments
 (0)