From e7947069d27ce2cbb7c42176660053569236de99 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 28 Sep 2022 23:39:12 -0400 Subject: [PATCH] Fix sourcegen compatibility with Python 3.8 --- interfaces/sourcegen/sourcegen/_HeaderFileParser.py | 3 ++- interfaces/sourcegen/sourcegen/_SourceGenerator.py | 3 ++- interfaces/sourcegen/sourcegen/_dataclasses.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/interfaces/sourcegen/sourcegen/_HeaderFileParser.py b/interfaces/sourcegen/sourcegen/_HeaderFileParser.py index 02dc42e657b..f355f26ad24 100644 --- a/interfaces/sourcegen/sourcegen/_HeaderFileParser.py +++ b/interfaces/sourcegen/sourcegen/_HeaderFileParser.py @@ -3,6 +3,7 @@ from pathlib import Path import re +from typing import List from ._dataclasses import HeaderFile, Func, Param @@ -28,7 +29,7 @@ def _parse_func(cls, c_func: str) -> Func: name = front[-1] return Func(ret_type, name, params) - def __init__(self, path: Path, ignore_funcs: list[str] = None): + def __init__(self, path: Path, ignore_funcs: List[str] = None): self._path = path self._ignore_funcs = ignore_funcs diff --git a/interfaces/sourcegen/sourcegen/_SourceGenerator.py b/interfaces/sourcegen/sourcegen/_SourceGenerator.py index 368b909a043..9c97445a287 100644 --- a/interfaces/sourcegen/sourcegen/_SourceGenerator.py +++ b/interfaces/sourcegen/sourcegen/_SourceGenerator.py @@ -3,6 +3,7 @@ from abc import ABCMeta, abstractmethod from pathlib import Path +from typing import List from ._dataclasses import HeaderFile @@ -15,5 +16,5 @@ def __init__(self, out_dir: Path, config: dict): pass @abstractmethod - def generate_source(self, headers_files: list[HeaderFile]): + def generate_source(self, headers_files: List[HeaderFile]): pass diff --git a/interfaces/sourcegen/sourcegen/_dataclasses.py b/interfaces/sourcegen/sourcegen/_dataclasses.py index 02d5bd9aaf7..3743d9abaea 100644 --- a/interfaces/sourcegen/sourcegen/_dataclasses.py +++ b/interfaces/sourcegen/sourcegen/_dataclasses.py @@ -3,6 +3,7 @@ from dataclasses import dataclass from pathlib import Path +from typing import List import re from ._helpers import with_unpack_iter @@ -23,7 +24,7 @@ class Func: ret_type: str name: str - params: list[Param] + params: List[Param] @dataclass(frozen=True) @@ -32,4 +33,4 @@ class HeaderFile: """Represents information about a parsed C header file""" path: Path - funcs: list[Func] + funcs: List[Func]