Skip to content

Commit 7652bba

Browse files
authored
Replace deprecated constants with enums (#229)
2 parents 452771e + d6cc0d2 commit 7652bba

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dynamic = [ "version" ]
3737
dependencies = [
3838
"httpx>=0.19",
3939
"platformdirs",
40-
"prettytable>=2.4",
40+
"prettytable>=3.12",
4141
"pytablewriter[html]>=0.63",
4242
"python-dateutil",
4343
"python-slugify",

src/norwegianblue/__init__.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -227,29 +227,31 @@ def _prettytable(
227227
color: str = "yes",
228228
title: str | None = None,
229229
) -> str:
230-
from prettytable import MARKDOWN, SINGLE_BORDER, PrettyTable
230+
from prettytable import PrettyTable, TableStyle
231231

232-
x = PrettyTable()
233-
x.set_style(MARKDOWN if format_ == "markdown" else SINGLE_BORDER)
232+
table = PrettyTable()
233+
table.set_style(
234+
TableStyle.MARKDOWN if format_ == "markdown" else TableStyle.SINGLE_BORDER
235+
)
234236
do_color = color != "no" and format_ == "pretty"
235237

236238
for header in headers:
237239
left_align = header in ("cycle", "latest", "link")
238240
display_header = colored(header, attrs=["bold"]) if do_color else header
239241
col_data = [row[header] if header in row else "" for row in data]
240-
x.add_column(display_header, col_data)
242+
table.add_column(display_header, col_data)
241243

242244
if left_align:
243-
x.align[display_header] = "l"
245+
table.align[display_header] = "l"
244246

245247
title_prefix = ""
246248
if title:
247249
if format_ == "pretty":
248-
x.title = colored(title, attrs=["bold"]) if do_color else title
250+
table.title = colored(title, attrs=["bold"]) if do_color else title
249251
else:
250252
title_prefix = f"## {title}\n\n"
251253

252-
return title_prefix + x.get_string()
254+
return title_prefix + table.get_string()
253255

254256

255257
def _pytablewriter(

0 commit comments

Comments
 (0)