code_relocation: fix ruff UP006 and UP035 warnings

PEP585 enabled collections in the Python standard library (like tuple) to
be used as generic type annotations directly, instead of importing
analogous members from the typing module (like typing.Tuple).

The ruff python linter produces a UP006 warning if the deprecated type
annotations continue to be used.

This patch corrects the issue by correcting the single instance where
PEP585-style type annotations can be used.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
This commit is contained in:
Joel Holdsworth 2025-05-21 10:35:32 -07:00 committed by Benjamin Cabé
commit 8ee466337e
2 changed files with 2 additions and 4 deletions

View file

@ -234,8 +234,6 @@
] ]
"./scripts/build/gen_relocate_app.py" = [ "./scripts/build/gen_relocate_app.py" = [
"E101", # https://docs.astral.sh/ruff/rules/mixed-spaces-and-tabs "E101", # https://docs.astral.sh/ruff/rules/mixed-spaces-and-tabs
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation
"UP035", # https://docs.astral.sh/ruff/rules/deprecated-import
"UP037", # https://docs.astral.sh/ruff/rules/quoted-annotation "UP037", # https://docs.astral.sh/ruff/rules/quoted-annotation
] ]
"./scripts/build/gen_strerror_table.py" = [ "./scripts/build/gen_strerror_table.py" = [

View file

@ -49,7 +49,7 @@ import warnings
from collections import defaultdict from collections import defaultdict
from enum import Enum from enum import Enum
from pathlib import Path from pathlib import Path
from typing import NamedTuple, NewType, Tuple from typing import NamedTuple, NewType
from elftools.elf.elffile import ELFFile from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection from elftools.elf.sections import SymbolTableSection
@ -297,7 +297,7 @@ def assign_to_correct_mem_region(
return {MemoryRegion(memory_region): output_sections} return {MemoryRegion(memory_region): output_sections}
def section_kinds_from_memory_region(memory_region: str) -> 'Tuple[set[SectionKind], str]': def section_kinds_from_memory_region(memory_region: str) -> 'tuple[set[SectionKind], str]':
""" """
Get the section kinds requested by the given memory region name. Get the section kinds requested by the given memory region name.