projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fighting with type hints.
[python_utils.git]
/
conversion_utils.py
diff --git
a/conversion_utils.py
b/conversion_utils.py
index 8eaecd5bd7b8227b6cf8baeee4723e6bfa0450ed..cf4fcaab93f75291d7e24bf54d55f672eace1578 100644
(file)
--- a/
conversion_utils.py
+++ b/
conversion_utils.py
@@
-1,4
+1,7
@@
#!/usr/bin/env python3
#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""Utilities involving converting between different units."""
from typing import Callable, SupportsFloat
from typing import Callable, SupportsFloat
@@
-106,9
+109,7
@@
def convert(magnitude: SupportsFloat, from_thing: str, to_thing: str) -> float:
return _convert(magnitude, src, dst)
return _convert(magnitude, src, dst)
-def _convert(
- magnitude: SupportsFloat, from_unit: Converter, to_unit: Converter
-) -> float:
+def _convert(magnitude: SupportsFloat, from_unit: Converter, to_unit: Converter) -> float:
canonical = from_unit.to_canonical(magnitude)
converted = to_unit.from_canonical(canonical)
return float(converted)
canonical = from_unit.to_canonical(magnitude)
converted = to_unit.from_canonical(canonical)
return float(converted)