Skip to content

Commit

Permalink
Typehint wrapping (hgrecco#1436)
Browse files Browse the repository at this point in the history
fixed type hints in function wrapper
  • Loading branch information
Suseko authored Dec 11, 2021
1 parent 3fa23e8 commit c686837
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Other contributors, listed alphabetically, are:
* Ryan Dwyer <[email protected]>
* Ryan Kingsbury <[email protected]>
* Ryan May
* Sebastian Kosmeier
* Sigvald Marholm <[email protected]>
* Sundar Raman <[email protected]>
* Tiago Coutinho <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Pint Changelog
0.19 (unreleased)
-----------------

- Fix type hints of function wrapper (Issue #1431)
- Upgrade min version of uncertainties to 3.1.4
- Fix setting options of the application registry (Issue #1403).
- Fix Quantity & Unit `is_compatible_with` with registry active contexts (Issue #1424).
Expand Down
10 changes: 5 additions & 5 deletions pint/registry_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def _apply_defaults(func, args, kwargs):

def wraps(
ureg: "UnitRegistry",
ret: Union[str, "Unit", Iterable[str], Iterable["Unit"], None],
args: Union[str, "Unit", Iterable[str], Iterable["Unit"], None],
ret: Union[str, "Unit", Iterable[Union[str, "Unit", None]], None],
args: Union[str, "Unit", Iterable[Union[str, "Unit", None]], None],
strict: bool = True,
) -> Callable[[Callable[..., T]], Callable[..., Quantity[T]]]:
"""Wraps a function to become pint-aware.
Expand All @@ -204,9 +204,9 @@ def wraps(
----------
ureg : pint.UnitRegistry
a UnitRegistry instance.
ret : str, pint.Unit, iterable of str, or iterable of pint.Unit
ret : str, pint.Unit, or iterable of str or pint.Unit
Units of each of the return values. Use `None` to skip argument conversion.
args : str, pint.Unit, iterable of str, or iterable of pint.Unit
args : str, pint.Unit, or iterable of str or pint.Unit
Units of each of the input arguments. Use `None` to skip argument conversion.
strict : bool
Indicates that only quantities are accepted. (Default value = True)
Expand All @@ -220,7 +220,7 @@ def wraps(
------
TypeError
if the number of given arguments does not match the number of function parameters.
if the any of the provided arguments is not a unit a string or Quantity
if any of the provided arguments is not a unit a string or Quantity
"""

Expand Down

0 comments on commit c686837

Please sign in to comment.