diff --git a/pint/compat.py b/pint/compat.py index 29fd00285..c379e7222 100644 --- a/pint/compat.py +++ b/pint/compat.py @@ -99,7 +99,7 @@ class BehaviorChangeWarning(UserWarning): else: NUMERIC_TYPES = (Number, Decimal, ndarray, np.number) - def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False): + def _to_magnitude(value, force_ndarray: bool=False, force_ndarray_like: bool=False): if isinstance(value, (dict, bool)) or value is None: raise TypeError(f"Invalid magnitude for Quantity: {value!r}") elif isinstance(value, str) and value == "": @@ -149,7 +149,7 @@ class np_datetime64: HAS_NUMPY_ARRAY_FUNCTION = False NP_NO_VALUE = None - def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False): + def _to_magnitude(value, force_ndarray: bool=False, force_ndarray_like: bool=False): if force_ndarray or force_ndarray_like: raise ValueError( "Cannot force to ndarray or ndarray-like when NumPy is not present." diff --git a/pint/facets/measurement/objects.py b/pint/facets/measurement/objects.py index 99c0794e8..33728f1c3 100644 --- a/pint/facets/measurement/objects.py +++ b/pint/facets/measurement/objects.py @@ -20,7 +20,7 @@ class MeasurementQuantity(Generic[MagnitudeT], PlainQuantity[MagnitudeT]): # Measurement support - def plus_minus(self, error, relative=False): + def plus_minus(self, error, relative: bool=False): if isinstance(error, self.__class__): if relative: raise ValueError(f"{error} is not a valid relative error.") diff --git a/pint/facets/numpy/numpy_func.py b/pint/facets/numpy/numpy_func.py index fd27c5e1c..6a4683cc3 100644 --- a/pint/facets/numpy/numpy_func.py +++ b/pint/facets/numpy/numpy_func.py @@ -597,7 +597,7 @@ def _unwrap(p, discont=None, axis=-1): @implements("copyto", "function") -def _copyto(dst, src, casting="same_kind", where=True) -> None: +def _copyto(dst, src, casting="same_kind", where: bool=True) -> None: if _is_quantity(dst): if _is_quantity(src): src = src.m_as(dst.units) @@ -619,7 +619,7 @@ def _einsum(subscripts, *operands, **kwargs): @implements("isin", "function") -def _isin(element, test_elements, assume_unique=False, invert=False): +def _isin(element, test_elements, assume_unique: bool=False, invert: bool=False): if not _is_quantity(element): raise ValueError( "Cannot test if unit-aware elements are in not-unit-aware array" @@ -815,7 +815,7 @@ def implementation(a, b, **kwargs): # Implement simple matching-unit or stripped-unit functions based on signature -def implement_consistent_units_by_argument(func_str, unit_arguments, wrap_output=True) -> None: +def implement_consistent_units_by_argument(func_str, unit_arguments, wrap_output: bool=True) -> None: # If NumPy is not available, do not attempt implement that which does not exist if np is None: return diff --git a/pint/facets/plain/unit.py b/pint/facets/plain/unit.py index 0ee05abbc..242fdf31d 100644 --- a/pint/facets/plain/unit.py +++ b/pint/facets/plain/unit.py @@ -241,7 +241,7 @@ def systems(self): out.add(sname) return frozenset(out) - def from_(self, value, strict=True, name="value"): + def from_(self, value, strict: bool=True, name="value"): """Converts a numerical value or quantity to this unit Parameters @@ -268,7 +268,7 @@ def from_(self, value, strict=True, name="value"): else: return value * self - def m_from(self, value, strict=True, name="value"): + def m_from(self, value, strict: bool=True, name="value"): """Converts a numerical value or quantity to this unit, then returns the magnitude of the converted value diff --git a/pint/registry.py b/pint/registry.py index 913a790f7..df091291e 100644 --- a/pint/registry.py +++ b/pint/registry.py @@ -120,8 +120,8 @@ def __init__( autoconvert_offset_to_baseunit: bool = False, on_redefinition: str = "warn", system=None, - auto_reduce_dimensions=False, - autoconvert_to_preferred=False, + auto_reduce_dimensions: bool=False, + autoconvert_to_preferred: bool=False, preprocessors=None, fmt_locale=None, non_int_type=float,