11
11
from __future__ import annotations
12
12
13
13
from enum import Enum , unique
14
- from typing import Type , TypeVar
14
+ from typing import TypeVar
15
15
16
16
# Create a generic variable that can be 'Enum', or any subclass.
17
17
T = TypeVar ("T" , bound = "Enum" )
@@ -53,7 +53,7 @@ class SIUnit(Enum):
53
53
yocto = - 24
54
54
55
55
@classmethod
56
- def get_positive (cls : Type [T ]) -> dict :
56
+ def get_positive (cls : type [T ]) -> dict :
57
57
"""
58
58
Returns a dictionary with only the elements of this enum
59
59
that has a positive value
@@ -68,7 +68,7 @@ def get_positive(cls: Type[T]) -> dict:
68
68
return {unit .name : unit .value for unit in cls if unit .value > 0 }
69
69
70
70
@classmethod
71
- def get_negative (cls : Type [T ]) -> dict :
71
+ def get_negative (cls : type [T ]) -> dict :
72
72
"""
73
73
Returns a dictionary with only the elements of this enum
74
74
that has a negative value
@@ -94,7 +94,7 @@ def add_si_prefix(value: float) -> str:
94
94
"""
95
95
prefixes = SIUnit .get_positive () if value > 0 else SIUnit .get_negative ()
96
96
for name_prefix , value_prefix in prefixes .items ():
97
- numerical_part = value / (10 ** value_prefix )
97
+ numerical_part = value / (10 ** value_prefix )
98
98
if numerical_part > 1 :
99
99
return f"{ str (numerical_part )} { name_prefix } "
100
100
return str (value )
@@ -109,7 +109,7 @@ def add_binary_prefix(value: float) -> str:
109
109
'64.0 kilo'
110
110
"""
111
111
for prefix in BinaryUnit :
112
- numerical_part = value / (2 ** prefix .value )
112
+ numerical_part = value / (2 ** prefix .value )
113
113
if numerical_part > 1 :
114
114
return f"{ str (numerical_part )} { prefix .name } "
115
115
return str (value )
0 commit comments