Skip to content

Commit ce8f2ac

Browse files
committed
Fix: Don't use newer Python type feature
1 parent fb29cbf commit ce8f2ac

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

django_utils_lib/logger.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import logging
22
from os import get_terminal_size
3-
from typing import List
3+
from typing import List, Union
44

55
from django_utils_lib.constants import PACKAGE_NAME
66

77
pkg_logger = logging.getLogger(PACKAGE_NAME)
88
pkg_logger.setLevel(logging.INFO)
99

1010

11-
def build_heading_block(heading: str | List[str], border_width=2) -> str:
11+
def build_heading_block(heading: Union[str, List[str]], border_width=2) -> str:
1212
"""
1313
Generate a heading, like:
1414
```
@@ -26,15 +26,9 @@ def build_heading_block(heading: str | List[str], border_width=2) -> str:
2626
border_width_total = border_width + 1
2727

2828
for line in heading if isinstance(heading, list) else heading.splitlines():
29-
left_inner_padding = int(
30-
(terminal_width - len(line) - (border_width_total * 2)) / 2
31-
)
32-
right_inner_padding = int(
33-
terminal_width - left_inner_padding - len(line) - (border_width_total * 2)
34-
)
35-
heading_lines.append(
36-
f"{border} {' ' * left_inner_padding}{line}{' ' * right_inner_padding} {border}"
37-
)
29+
left_inner_padding = int((terminal_width - len(line) - (border_width_total * 2)) / 2)
30+
right_inner_padding = int(terminal_width - left_inner_padding - len(line) - (border_width_total * 2))
31+
heading_lines.append(f"{border} {' ' * left_inner_padding}{line}{' ' * right_inner_padding} {border}")
3832
heading_lines.append(heading_delim)
3933

4034
return "\n".join(heading_lines)

0 commit comments

Comments
 (0)