Skip to content

Commit c167a69

Browse files
committed
Drop Python 3.6 Support
Main features of Python 3.7 being utilized is `from __future__ import annotations` and dataclasses.
1 parent 3c6d1f1 commit c167a69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1049
-985
lines changed

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-20.04
1313
strategy:
1414
matrix:
15-
python-version: ["3.6"]
15+
python-version: ["3.7"]
1616

1717
steps:
1818
- uses: actions/checkout@v3

Colors.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from __future__ import annotations
12
import random
23
import re
34
from collections import namedtuple
4-
from typing import Dict, Tuple, List
55

66
Color = namedtuple('Color', ' R G B')
77

8-
tunic_colors: Dict[str, Color] = {
8+
tunic_colors: dict[str, Color] = {
99
"Kokiri Green": Color(0x1E, 0x69, 0x1B),
1010
"Goron Red": Color(0x64, 0x14, 0x00),
1111
"Zora Blue": Color(0x00, 0x3C, 0x64),
@@ -40,7 +40,7 @@
4040
}
4141

4242
# Inner Core Color Outer Glow Color
43-
NaviColors: Dict[str, Tuple[Color, Color]] = {
43+
NaviColors: dict[str, tuple[Color, Color]] = {
4444
"Rainbow": (Color(0x00, 0x00, 0x00), Color(0x00, 0x00, 0x00)),
4545
"Gold": (Color(0xFE, 0xCC, 0x3C), Color(0xFE, 0xC0, 0x07)),
4646
"White": (Color(0xFF, 0xFF, 0xFF), Color(0x00, 0x00, 0xFF)),
@@ -63,7 +63,7 @@
6363
"Phantom Zelda": (Color(0x97, 0x7A, 0x6C), Color(0x6F, 0x46, 0x67)),
6464
}
6565

66-
sword_trail_colors: Dict[str, Color] = {
66+
sword_trail_colors: dict[str, Color] = {
6767
"Rainbow": Color(0x00, 0x00, 0x00),
6868
"White": Color(0xFF, 0xFF, 0xFF),
6969
"Red": Color(0xFF, 0x00, 0x00),
@@ -77,7 +77,7 @@
7777
"Pink": Color(0xFF, 0x69, 0xB4),
7878
}
7979

80-
bombchu_trail_colors: Dict[str, Color] = {
80+
bombchu_trail_colors: dict[str, Color] = {
8181
"Rainbow": Color(0x00, 0x00, 0x00),
8282
"Red": Color(0xFA, 0x00, 0x00),
8383
"Green": Color(0x00, 0xFF, 0x00),
@@ -90,7 +90,7 @@
9090
"Pink": Color(0xFF, 0x69, 0xB4),
9191
}
9292

93-
boomerang_trail_colors: Dict[str, Color] = {
93+
boomerang_trail_colors: dict[str, Color] = {
9494
"Rainbow": Color(0x00, 0x00, 0x00),
9595
"Yellow": Color(0xFF, 0xFF, 0x64),
9696
"Red": Color(0xFF, 0x00, 0x00),
@@ -104,7 +104,7 @@
104104
"Pink": Color(0xFF, 0x69, 0xB4),
105105
}
106106

107-
gauntlet_colors: Dict[str, Color] = {
107+
gauntlet_colors: dict[str, Color] = {
108108
"Silver": Color(0xFF, 0xFF, 0xFF),
109109
"Gold": Color(0xFE, 0xCF, 0x0F),
110110
"Black": Color(0x00, 0x00, 0x06),
@@ -120,7 +120,7 @@
120120
"Purple": Color(0x80, 0x00, 0x80),
121121
}
122122

123-
shield_frame_colors: Dict[str, Color] = {
123+
shield_frame_colors: dict[str, Color] = {
124124
"Red": Color(0xD7, 0x00, 0x00),
125125
"Green": Color(0x00, 0xFF, 0x00),
126126
"Blue": Color(0x00, 0x40, 0xD8),
@@ -133,14 +133,14 @@
133133
"Pink": Color(0xFF, 0x69, 0xB4),
134134
}
135135

136-
heart_colors: Dict[str, Color] = {
136+
heart_colors: dict[str, Color] = {
137137
"Red": Color(0xFF, 0x46, 0x32),
138138
"Green": Color(0x46, 0xC8, 0x32),
139139
"Blue": Color(0x32, 0x46, 0xFF),
140140
"Yellow": Color(0xFF, 0xE0, 0x00),
141141
}
142142

143-
magic_colors: Dict[str, Color] = {
143+
magic_colors: dict[str, Color] = {
144144
"Green": Color(0x00, 0xC8, 0x00),
145145
"Red": Color(0xC8, 0x00, 0x00),
146146
"Blue": Color(0x00, 0x30, 0xFF),
@@ -152,7 +152,7 @@
152152

153153
# A Button Text Cursor Shop Cursor Save/Death Cursor
154154
# Pause Menu A Cursor Pause Menu A Icon A Note
155-
a_button_colors: Dict[str, Tuple[Color, Color, Color, Color, Color, Color, Color]] = {
155+
a_button_colors: dict[str, tuple[Color, Color, Color, Color, Color, Color, Color]] = {
156156
"N64 Blue": (Color(0x5A, 0x5A, 0xFF), Color(0x00, 0x50, 0xC8), Color(0x00, 0x50, 0xFF), Color(0x64, 0x64, 0xFF),
157157
Color(0x00, 0x32, 0xFF), Color(0x00, 0x64, 0xFF), Color(0x50, 0x96, 0xFF)),
158158
"N64 Green": (Color(0x00, 0x96, 0x00), Color(0x00, 0x96, 0x00), Color(0x00, 0x96, 0x00), Color(0x64, 0x96, 0x64),
@@ -188,7 +188,7 @@
188188
}
189189

190190
# B Button
191-
b_button_colors: Dict[str, Color] = {
191+
b_button_colors: dict[str, Color] = {
192192
"N64 Blue": Color(0x5A, 0x5A, 0xFF),
193193
"N64 Green": Color(0x00, 0x96, 0x00),
194194
"N64 Red": Color(0xC8, 0x00, 0x00),
@@ -208,7 +208,7 @@
208208
}
209209

210210
# C Button Pause Menu C Cursor Pause Menu C Icon C Note
211-
c_button_colors: Dict[str, Tuple[Color, Color, Color, Color]] = {
211+
c_button_colors: dict[str, tuple[Color, Color, Color, Color]] = {
212212
"N64 Blue": (Color(0x5A, 0x5A, 0xFF), Color(0x00, 0x32, 0xFF), Color(0x00, 0x64, 0xFF), Color(0x50, 0x96, 0xFF)),
213213
"N64 Green": (Color(0x00, 0x96, 0x00), Color(0x00, 0x96, 0x00), Color(0x00, 0x96, 0x00), Color(0x00, 0x96, 0x00)),
214214
"N64 Red": (Color(0xC8, 0x00, 0x00), Color(0xC8, 0x00, 0x00), Color(0xC8, 0x00, 0x00), Color(0xC8, 0x00, 0x00)),
@@ -228,7 +228,7 @@
228228
}
229229

230230
# Start Button
231-
start_button_colors: Dict[str, Color] = {
231+
start_button_colors: dict[str, Color] = {
232232
"N64 Blue": Color(0x5A, 0x5A, 0xFF),
233233
"N64 Green": Color(0x00, 0x96, 0x00),
234234
"N64 Red": Color(0xC8, 0x00, 0x00),
@@ -247,133 +247,133 @@
247247
"Orange": Color(0xFF, 0x80, 0x00),
248248
}
249249

250-
meta_color_choices: List[str] = ["Random Choice", "Completely Random", "Custom Color"]
250+
meta_color_choices: list[str] = ["Random Choice", "Completely Random", "Custom Color"]
251251

252252

253-
def get_tunic_colors() -> List[str]:
253+
def get_tunic_colors() -> list[str]:
254254
return list(tunic_colors.keys())
255255

256256

257-
def get_tunic_color_options() -> List[str]:
257+
def get_tunic_color_options() -> list[str]:
258258
return meta_color_choices + ["Rainbow"] + get_tunic_colors()
259259

260260

261-
def get_navi_colors() -> List[str]:
261+
def get_navi_colors() -> list[str]:
262262
return list(NaviColors.keys())
263263

264264

265-
def get_navi_color_options(outer: bool = False) -> List[str]:
265+
def get_navi_color_options(outer: bool = False) -> list[str]:
266266
if outer:
267267
return ["[Same as Inner]"] + meta_color_choices + get_navi_colors()
268268
else:
269269
return meta_color_choices + get_navi_colors()
270270

271271

272-
def get_sword_trail_colors() -> List[str]:
272+
def get_sword_trail_colors() -> list[str]:
273273
return list(sword_trail_colors.keys())
274274

275275

276-
def get_sword_trail_color_options(outer: bool = False) -> List[str]:
276+
def get_sword_trail_color_options(outer: bool = False) -> list[str]:
277277
if outer:
278278
return ["[Same as Inner]"] + meta_color_choices + get_sword_trail_colors()
279279
else:
280280
return meta_color_choices + get_sword_trail_colors()
281281

282282

283-
def get_bombchu_trail_colors() -> List[str]:
283+
def get_bombchu_trail_colors() -> list[str]:
284284
return list(bombchu_trail_colors.keys())
285285

286286

287-
def get_bombchu_trail_color_options(outer: bool = False) -> List[str]:
287+
def get_bombchu_trail_color_options(outer: bool = False) -> list[str]:
288288
if outer:
289289
return ["[Same as Inner]"] + meta_color_choices + get_bombchu_trail_colors()
290290
else:
291291
return meta_color_choices + get_bombchu_trail_colors()
292292

293293

294-
def get_boomerang_trail_colors() -> List[str]:
294+
def get_boomerang_trail_colors() -> list[str]:
295295
return list(boomerang_trail_colors.keys())
296296

297297

298-
def get_boomerang_trail_color_options(outer: bool = False) -> List[str]:
298+
def get_boomerang_trail_color_options(outer: bool = False) -> list[str]:
299299
if outer:
300300
return ["[Same as Inner]"] + meta_color_choices + get_boomerang_trail_colors()
301301
else:
302302
return meta_color_choices + get_boomerang_trail_colors()
303303

304304

305-
def get_gauntlet_colors() -> List[str]:
305+
def get_gauntlet_colors() -> list[str]:
306306
return list(gauntlet_colors.keys())
307307

308308

309-
def get_gauntlet_color_options() -> List[str]:
309+
def get_gauntlet_color_options() -> list[str]:
310310
return meta_color_choices + get_gauntlet_colors()
311311

312312

313-
def get_shield_frame_colors() -> List[str]:
313+
def get_shield_frame_colors() -> list[str]:
314314
return list(shield_frame_colors.keys())
315315

316316

317-
def get_shield_frame_color_options() -> List[str]:
317+
def get_shield_frame_color_options() -> list[str]:
318318
return meta_color_choices + get_shield_frame_colors()
319319

320320

321-
def get_heart_colors() -> List[str]:
321+
def get_heart_colors() -> list[str]:
322322
return list(heart_colors.keys())
323323

324324

325-
def get_heart_color_options() -> List[str]:
325+
def get_heart_color_options() -> list[str]:
326326
return meta_color_choices + get_heart_colors()
327327

328328

329-
def get_magic_colors() -> List[str]:
329+
def get_magic_colors() -> list[str]:
330330
return list(magic_colors.keys())
331331

332332

333-
def get_magic_color_options() -> List[str]:
333+
def get_magic_color_options() -> list[str]:
334334
return meta_color_choices + get_magic_colors()
335335

336336

337-
def get_a_button_colors() -> List[str]:
337+
def get_a_button_colors() -> list[str]:
338338
return list(a_button_colors.keys())
339339

340340

341-
def get_a_button_color_options() -> List[str]:
341+
def get_a_button_color_options() -> list[str]:
342342
return meta_color_choices + get_a_button_colors()
343343

344344

345-
def get_b_button_colors() -> List[str]:
345+
def get_b_button_colors() -> list[str]:
346346
return list(b_button_colors.keys())
347347

348348

349-
def get_b_button_color_options() -> List[str]:
349+
def get_b_button_color_options() -> list[str]:
350350
return meta_color_choices + get_b_button_colors()
351351

352352

353-
def get_c_button_colors() -> List[str]:
353+
def get_c_button_colors() -> list[str]:
354354
return list(c_button_colors.keys())
355355

356356

357-
def get_c_button_color_options() -> List[str]:
357+
def get_c_button_color_options() -> list[str]:
358358
return meta_color_choices + get_c_button_colors()
359359

360360

361-
def get_start_button_colors() -> List[str]:
361+
def get_start_button_colors() -> list[str]:
362362
return list(start_button_colors.keys())
363363

364364

365-
def get_start_button_color_options() -> List[str]:
365+
def get_start_button_color_options() -> list[str]:
366366
return meta_color_choices + get_start_button_colors()
367367

368368

369-
def contrast_ratio(color1: List[int], color2: List[int]) -> float:
369+
def contrast_ratio(color1: list[int], color2: list[int]) -> float:
370370
# Based on accessibility standards (WCAG 2.0)
371371
lum1 = relative_luminance(color1)
372372
lum2 = relative_luminance(color2)
373373
return (max(lum1, lum2) + 0.05) / (min(lum1, lum2) + 0.05)
374374

375375

376-
def relative_luminance(color: List[int]) -> float:
376+
def relative_luminance(color: list[int]) -> float:
377377
color_ratios = list(map(lum_color_ratio, color))
378378
return color_ratios[0] * 0.299 + color_ratios[1] * 0.587 + color_ratios[2] * 0.114
379379

@@ -386,11 +386,11 @@ def lum_color_ratio(val: float) -> float:
386386
return pow((val + 0.055) / 1.055, 2.4)
387387

388388

389-
def generate_random_color() -> List[int]:
389+
def generate_random_color() -> list[int]:
390390
return [random.getrandbits(8), random.getrandbits(8), random.getrandbits(8)]
391391

392392

393-
def hex_to_color(option: str) -> List[int]:
393+
def hex_to_color(option: str) -> list[int]:
394394
if not hasattr(hex_to_color, "regex"):
395395
hex_to_color.regex = re.compile(r'^(?:[0-9a-fA-F]{3}){1,2}$')
396396

@@ -404,5 +404,5 @@ def hex_to_color(option: str) -> List[int]:
404404
return list(int(f'{option[i]}{option[i]}', 16) for i in (0, 1, 2))
405405

406406

407-
def color_to_hex(color: List[int]) -> str:
407+
def color_to_hex(color: list[int]) -> str:
408408
return '#' + ''.join(['{:02X}'.format(c) for c in color])

0 commit comments

Comments
 (0)