Skip to content

Commit

Permalink
pyupgrade 3.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Aug 6, 2024
1 parent c32d217 commit 9ff6655
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion skytemple_dtef/dungeon_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@


class RestTileMappingEntry:
def __init__(self, dmatype_name: Union[Literal["normal"], Literal["extra"]], dmatype_idx: int, neighbors: int, variation_or_index: int):
def __init__(self, dmatype_name: Literal["normal"] | Literal["extra"], dmatype_idx: int, neighbors: int, variation_or_index: int):
self.dmatype_name = dmatype_name
self.dmatype_idx = dmatype_idx
self.neighbors = neighbors
Expand Down
8 changes: 4 additions & 4 deletions skytemple_dtef/explorers_dtef_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def __init__(self, dma: DmaProtocol, dpc: DpcProtocol, dpci: DpciProtocol, dpl:
self.dpl = dpl
self.dpla = dpla

self._dirname: Optional[str] = None
self._dirname: str | None = None
self._tileset_file_map: dict[str, Image.Image] = {}
self._tileset_chunk_map: dict[str, dict[tuple[int, int], int]] = {}
self._xml: Optional[Element] = None
self._xml: Element | None = None

# The individual
self._chunks: list[Image.Image] = [Image.new('P', (CHUNK_DIM, CHUNK_DIM))]
self._palette: Optional[bytes] = None
self._palette: bytes | None = None
self._dpla__colors: list[list[int]] = []
self._dpla__durations_per_frame_for_colors: list[int] = []
self._dma__original_chunk_mappings = dma.chunk_mappings
Expand Down Expand Up @@ -144,7 +144,7 @@ def _open_tileset(self, fn):
'The palettes of the images do not match. First image read that didn\'t match: '
'"{basename}"')))

def _import_tileset(self, fn: str, rule_map: dict[int, set[int]], typ: int, bx, by, w, h, var_id, prev_fn: Optional[str]):
def _import_tileset(self, fn: str, rule_map: dict[int, set[int]], typ: int, bx, by, w, h, var_id, prev_fn: str | None):
assert fn in self._tileset_file_map, f(_("Logic error: Tileset file {fn} was not loaded."))
assert fn in self._tileset_chunk_map, f(_("Logic error: Tileset file {fn} was not loaded."))
tileset = self._tileset_file_map[fn]
Expand Down
2 changes: 1 addition & 1 deletion skytemple_dtef/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
]


def get_rule_variations(input_rules: Iterable[Optional[int]]) -> dict[int, set[int]]:
def get_rule_variations(input_rules: Iterable[int | None]) -> dict[int, set[int]]:
"""
Returns all 256-set rules which encode the same tile in a reduced rule-set of 47 rules
(including the rule passed in). If the rule passed in is None, an empty list is returned.
Expand Down
2 changes: 1 addition & 1 deletion skytemple_dtef/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def xml_filter_tags(xml: Element, tag_list) -> Element:
return new_ele


def convert_hex_str_color_to_tuple(h: str) -> Optional[tuple[int, int, int]]:
def convert_hex_str_color_to_tuple(h: str) -> tuple[int, int, int] | None:
if h is None:
return None
return tuple(int(h[i:i+2], 16) for i in (0, 2, 4)) # type: ignore
Expand Down

0 comments on commit 9ff6655

Please sign in to comment.