Skip to content

Commit

Permalink
--none-return
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage committed Jan 18, 2025
1 parent 9b6b384 commit a8ae9b7
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _unpickle_measurement(cls, *args):
return _unpickle(application_registry.Measurement, *args)


def set_application_registry(registry):
def set_application_registry(registry) -> None:
"""Set the application registry, which is used for unpickling operations
and when invoking pint.Quantity or pint.Unit directly.
Expand Down
2 changes: 1 addition & 1 deletion pint/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _test_array_function_protocol():
try:

class FakeArray:
def __array_function__(self, *args, **kwargs):
def __array_function__(self, *args, **kwargs) -> None:
return

np.concatenate([FakeArray()])
Expand Down
2 changes: 1 addition & 1 deletion pint/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def to_reference(self, value: Magnitude, inplace: bool = False) -> Magnitude:
def from_reference(self, value: Magnitude, inplace: bool = False) -> Magnitude:
return value

def __init_subclass__(cls, **kwargs: Any):
def __init_subclass__(cls, **kwargs: Any) -> None:
# Get constructor parameters
super().__init_subclass__(**kwargs)
cls._subclasses.append(cls)
Expand Down
2 changes: 1 addition & 1 deletion pint/delegates/formatter/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FullFormatter(BaseFormatter):

locale: Locale | None = None

def __init__(self, registry: UnitRegistry | None = None):
def __init__(self, registry: UnitRegistry | None = None) -> None:
super().__init__(registry)

self._formatters = {}
Expand Down
2 changes: 1 addition & 1 deletion pint/delegates/formatter/plain.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@


class BaseFormatter:
def __init__(self, registry: UnitRegistry | None = None):
def __init__(self, registry: UnitRegistry | None = None) -> None:
self._registry = registry


Expand Down
2 changes: 1 addition & 1 deletion pint/delegates/txt_defparser/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DefinitionSyntaxError(errors.DefinitionSyntaxError, fp.ParsingError):

msg: str

def __init__(self, msg: str, location: str = ""):
def __init__(self, msg: str, location: str = "") -> None:
self.msg = msg
self.location = location

Expand Down
4 changes: 2 additions & 2 deletions pint/delegates/txt_defparser/defparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _PintParser(fp.Parser[PintRootBlock, ParserConfig]):

_diskcache: fc.DiskCache | None

def __init__(self, config: ParserConfig, *args: ty.Any, **kwargs: ty.Any):
def __init__(self, config: ParserConfig, *args: ty.Any, **kwargs: ty.Any) -> None:
self._diskcache = kwargs.pop("diskcache", None)
super().__init__(config, *args, **kwargs)

Expand All @@ -68,7 +68,7 @@ class DefParser:
plain.CommentDefinition,
)

def __init__(self, default_config: ParserConfig, diskcache: fc.DiskCache):
def __init__(self, default_config: ParserConfig, diskcache: fc.DiskCache) -> None:
self._default_config = default_config
self._diskcache = diskcache

Expand Down
12 changes: 6 additions & 6 deletions pint/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class DefinitionError(ValueError, PintError):
definition_type: type
msg: str

def __init__(self, name: str, definition_type: type, msg: str):
def __init__(self, name: str, definition_type: type, msg: str) -> None:
self.name = name
self.definition_type = definition_type
self.msg = msg
Expand All @@ -109,7 +109,7 @@ class DefinitionSyntaxError(ValueError, PintError):

msg: str

def __init__(self, msg: str):
def __init__(self, msg: str) -> None:
self.msg = msg

def __str__(self):
Expand All @@ -125,7 +125,7 @@ class RedefinitionError(ValueError, PintError):
name: str
definition_type: type

def __init__(self, name: str, definition_type: type):
def __init__(self, name: str, definition_type: type) -> None:
self.name = name
self.definition_type = definition_type

Expand All @@ -142,7 +142,7 @@ class UndefinedUnitError(AttributeError, PintError):

unit_names: tuple[str, ...]

def __init__(self, unit_names: str | ty.Iterable[str]):
def __init__(self, unit_names: str | ty.Iterable[str]) -> None:
if isinstance(unit_names, str):
self.unit_names = (unit_names,)
else:
Expand Down Expand Up @@ -266,7 +266,7 @@ def __reduce__(self):
class UnitStrippedWarning(UserWarning, PintError):
msg: str

def __init__(self, msg: str):
def __init__(self, msg: str) -> None:
self.msg = msg

def __reduce__(self):
Expand All @@ -280,7 +280,7 @@ class UnexpectedScaleInContainer(Exception):
class UndefinedBehavior(UserWarning, PintError):
msg: str

def __init__(self, msg: str):
def __init__(self, msg: str) -> None:
self.msg = msg

def __reduce__(self):
Expand Down
4 changes: 2 additions & 2 deletions pint/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class PintAxisInfo(matplotlib.units.AxisInfo):
"""Support default axis and tick labeling and default limits."""

def __init__(self, units):
def __init__(self, units) -> None:
"""Set the default label to the pretty-print of the unit."""
formatter = units._REGISTRY.mpl_formatter
super().__init__(label=formatter.format(units))
Expand All @@ -28,7 +28,7 @@ def __init__(self, units):
class PintConverter(matplotlib.units.ConversionInterface):
"""Implement support for pint within matplotlib's unit conversion framework."""

def __init__(self, registry):
def __init__(self, registry) -> None:
super().__init__()
self._reg = registry

Expand Down
6 changes: 3 additions & 3 deletions pint/pint_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
ureg.default_system = args.system


def _set(key: str, value):
def _set(key: str, value) -> None:
obj = ureg._units[key].converter
object.__setattr__(obj, "scale", value)

Expand Down Expand Up @@ -170,7 +170,7 @@ def _set(key: str, value):
ureg._build_cache()


def convert(u_from, u_to=None, unc=None, factor=None):
def convert(u_from, u_to=None, unc=None, factor=None) -> None:
prec_unc = 0
q = ureg.Quantity(u_from)
fmt = f".{args.prec}g"
Expand Down Expand Up @@ -206,7 +206,7 @@ def use_unc(num, fmt, prec_unc):
return max(0, min(prec_unc, unc))


def main():
def main() -> None:
convert(args.fr, args.to)


Expand Down
4 changes: 2 additions & 2 deletions pint/pint_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _power(left: Any, right: Any) -> Any:

# https://stackoverflow.com/a/1517965/1291237
class tokens_with_lookahead:
def __init__(self, iter):
def __init__(self, iter) -> None:
self.iter = iter
self.buffer = []

Expand Down Expand Up @@ -321,7 +321,7 @@ def __init__(
left: EvalTreeNode | TokenInfo,
operator: TokenInfo | None = None,
right: EvalTreeNode | None = None,
):
) -> None:
self.left = left
self.operator = operator
self.right = right
Expand Down
12 changes: 6 additions & 6 deletions pint/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(
non_int_type=float,
case_sensitive: bool = True,
cache_folder=None,
):
) -> None:
super().__init__(
filename=filename,
force_ndarray=force_ndarray,
Expand Down Expand Up @@ -181,10 +181,10 @@ def setup_matplotlib(self, enable: bool = True) -> None:


class LazyRegistry(Generic[facets.QuantityT, facets.UnitT]):
def __init__(self, args=None, kwargs=None):
def __init__(self, args=None, kwargs=None) -> None:
self.__dict__["params"] = args or (), kwargs or {}

def __init(self):
def __init(self) -> None:
args, kwargs = self.__dict__["params"]
kwargs["on_redefinition"] = "raise"
self.__class__ = UnitRegistry
Expand All @@ -197,7 +197,7 @@ def __getattr__(self, item):
self.__init()
return getattr(self, item)

def __setattr__(self, key, value):
def __setattr__(self, key, value) -> None:
if key == "__class__":
super().__setattr__(key, value)
else:
Expand All @@ -218,7 +218,7 @@ class ApplicationRegistry:

__slots__ = ["_registry"]

def __init__(self, registry):
def __init__(self, registry) -> None:
self._registry = registry

def get(self):
Expand Down Expand Up @@ -250,7 +250,7 @@ def set(self, new_registry):
def __getattr__(self, name):
return getattr(self._registry, name)

def __setattr__(self, name, value):
def __setattr__(self, name, value) -> None:
if name in self.__slots__:
super().__setattr__(name, value)
else:
Expand Down
8 changes: 4 additions & 4 deletions pint/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def __hash__(self) -> int:
def __getstate__(self) -> tuple[udict, Scalar, type]:
return self._d, self._one, self._non_int_type

def __setstate__(self, state: tuple[udict, Scalar, type]):
def __setstate__(self, state: tuple[udict, Scalar, type]) -> None:
self._d, self._one, self._non_int_type = state
self._hash = None

Expand Down Expand Up @@ -706,7 +706,7 @@ class ParserHelper(UnitsContainer):

scale: Scalar

def __init__(self, scale: Scalar = 1, *args, **kwargs):
def __init__(self, scale: Scalar = 1, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.scale = scale

Expand Down Expand Up @@ -813,7 +813,7 @@ def __hash__(self):
def __getstate__(self):
return super().__getstate__() + (self.scale,)

def __setstate__(self, state):
def __setstate__(self, state) -> None:
super().__setstate__(state[:-1])
self.scale = state[-1]

Expand Down Expand Up @@ -1016,7 +1016,7 @@ def _repr_latex_(self) -> str:
return f"${self:~L}$"
return f"${self:L}$"

def _repr_pretty_(self, p, cycle: bool):
def _repr_pretty_(self, p, cycle: bool) -> None:
# if cycle:
if "~" in self._REGISTRY.formatter.default_format:
p.text(f"{self:~P}")
Expand Down

0 comments on commit a8ae9b7

Please sign in to comment.