Skip to content

fix black at prefix string #6122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions conversions/prefix_conversions_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from __future__ import annotations

from enum import Enum, unique
from typing import Type, TypeVar
from typing import TypeVar

# Create a generic variable that can be 'Enum', or any subclass.
T = TypeVar("T", bound="Enum")
Expand Down Expand Up @@ -53,7 +53,7 @@ class SIUnit(Enum):
yocto = -24

@classmethod
def get_positive(cls: Type[T]) -> dict:
def get_positive(cls: type[T]) -> dict:
"""
Returns a dictionary with only the elements of this enum
that has a positive value
Expand All @@ -68,7 +68,7 @@ def get_positive(cls: Type[T]) -> dict:
return {unit.name: unit.value for unit in cls if unit.value > 0}

@classmethod
def get_negative(cls: Type[T]) -> dict:
def get_negative(cls: type[T]) -> dict:
"""
Returns a dictionary with only the elements of this enum
that has a negative value
Expand All @@ -94,7 +94,7 @@ def add_si_prefix(value: float) -> str:
"""
prefixes = SIUnit.get_positive() if value > 0 else SIUnit.get_negative()
for name_prefix, value_prefix in prefixes.items():
numerical_part = value / (10 ** value_prefix)
numerical_part = value / (10**value_prefix)
if numerical_part > 1:
return f"{str(numerical_part)} {name_prefix}"
return str(value)
Expand All @@ -109,7 +109,7 @@ def add_binary_prefix(value: float) -> str:
'64.0 kilo'
"""
for prefix in BinaryUnit:
numerical_part = value / (2 ** prefix.value)
numerical_part = value / (2**prefix.value)
if numerical_part > 1:
return f"{str(numerical_part)} {prefix.name}"
return str(value)
Expand Down