Cleanup: update use of typing in for Python scripts

This commit is contained in:
Campbell Barton
2024-10-23 12:48:09 +11:00
parent 39b9863cca
commit a0453ab87a
40 changed files with 287 additions and 367 deletions

View File

@@ -4,7 +4,10 @@
from __future__ import annotations
import enum
import typing as t
from collections.abc import (
Sequence,
)
# Does not actually exist.
@@ -50,11 +53,11 @@ class Type:
sizeof: int
code: TypeCode
dynamic: bool
name: t.Optional[str]
tag: t.Optional[str]
objfile: t.Optional[Objfile]
name: str | None
tag: str | None
objfile: Objfile | None
def fields(self) -> t.List[Field]:
def fields(self) -> list[Field]:
pass
def array(self, n1, n2=None) -> Type:
@@ -87,7 +90,7 @@ class Type:
def target(self) -> Type:
pass
def template_argument(self, n, block=None) -> t.Union[Type, Value]:
def template_argument(self, n, block=None) -> type | Value:
pass
def optimized_out(self) -> Value:
@@ -97,7 +100,7 @@ class Type:
class Field:
bitpos: int
enumval: int
name: t.Optional[str]
name: str | None
artificial: bool
is_base_class: bool
bitsize: int
@@ -107,7 +110,7 @@ class Field:
class Value:
type: Type
address: t.Optional[Value]
address: Value | None
is_optimized_out: bool
dynamic_type: Type
is_lazy: bool
@@ -142,7 +145,7 @@ class Value:
def reinterpret_cast(self, type: Type) -> Value:
pass
def __getitem__(self, subscript: t.Union[int, str]) -> Value:
def __getitem__(self, subscript: int | str) -> Value:
pass
@@ -184,7 +187,7 @@ class Command:
def invoke(self, argument: str, from_tty: bool):
pass
def complete(self, text: str, word: str) -> t.Union[t.Sequence[str], CompleteCode]:
def complete(self, text: str, word: str) -> Sequence[str] | CompleteCode:
pass

View File

@@ -3,7 +3,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from .gdb import Value
import typing as t
class PrettyPrinter:

View File

@@ -3,7 +3,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from gdb import Type, Field
import typing as t
def get_basic_type(type: Type) -> Type:
@@ -14,5 +13,5 @@ def has_field(type: Type) -> bool:
pass
def make_enum_dict(enum_type: Type) -> t.Dict[str, int]:
def make_enum_dict(enum_type: Type) -> dict[str, int]:
pass