Skip to content

Commit

Permalink
Change Python 3.9-style type annotations to older Python 3.8-style
Browse files Browse the repository at this point in the history
Using (lowercase) list or tuple with subscript type wasn't supported
until Python 3.9. This change thus improves compatibility with Python 3.8

Internal-tag: [#53526]
Signed-off-by: Krzysztof Obłonczek <[email protected]>
  • Loading branch information
koblonczek committed Jan 9, 2024
1 parent 5d1223f commit 5e40dfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions fpga_topwrap/elaboratable_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

from functools import lru_cache
from typing import Iterable, Mapping, Union
from typing import Iterable, List, Mapping, Union

from amaranth import *
from amaranth.build import Platform
Expand Down Expand Up @@ -35,7 +35,7 @@ def __init__(self, name: str, elaboratable: Elaboratable) -> None:
port_width=1, port_flow=wiring.In, name="rst", port_name="rst", iface_name=""
)

def get_ports(self) -> list[WrapperPort]:
def get_ports(self) -> List[WrapperPort]:
"""Return a list of external ports."""
return self._flatten_hier(self.get_ports_hier())

Expand Down Expand Up @@ -136,7 +136,7 @@ def _flatten_hier(self, hier: SignalMapping) -> Iterable[Signal]:
ports += [hier]
return ports

def _connect_ports(self, ports: SignalMapping, iface: InterfaceLike) -> list[Assign]:
def _connect_ports(self, ports: SignalMapping, iface: InterfaceLike) -> List[Assign]:
"""Returns a list of amaranth assignments between the wrapped elaboratable and external ports.
:param ports: nested dictionary of WrapperPorts mirroring that of iface's signature
Expand Down
12 changes: 6 additions & 6 deletions tests/tests_build/test_elaboratable_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2023 Antmicro
# SPDX-License-Identifier: Apache-2.0

from typing import Callable, Union
from typing import Callable, List, Tuple, Union

import pytest
from amaranth import *
Expand Down Expand Up @@ -115,7 +115,7 @@ def nested_signature_mapping() -> SignalMapping:


@pytest.fixture
def flattened_nested_signature_mapping() -> list[WrapperPort]:
def flattened_nested_signature_mapping() -> List[WrapperPort]:
return [
WrapperPort(
bounds=[15, 0, 15, 0],
Expand Down Expand Up @@ -217,7 +217,7 @@ def clock_domain_signals(elaboratable_wrapper: ElaboratableWrapper) -> SignalMap
@pytest.fixture
def interface_connections(
elaboratable: Elaboratable, nested_signature_mapping: SignalMapping
) -> list[tuple[Signal, Signal]]:
) -> List[Tuple[Signal, Signal]]:
m = elaboratable
d = nested_signature_mapping
return [
Expand Down Expand Up @@ -269,7 +269,7 @@ def test_flatten_hier(
self,
elaboratable_wrapper: ElaboratableWrapper,
nested_signature_mapping: SignalMapping,
flattened_nested_signature_mapping: list[WrapperPort],
flattened_nested_signature_mapping: List[WrapperPort],
) -> None:
def ordering(p):
return p.name
Expand Down Expand Up @@ -304,7 +304,7 @@ def test_get_ports_hier(
def test_get_ports(
self,
elaboratable_wrapper: ElaboratableWrapper,
flattened_nested_signature_mapping: list[WrapperPort],
flattened_nested_signature_mapping: List[WrapperPort],
clock_domain_signals: SignalMapping,
) -> None:
def ordering(p):
Expand All @@ -322,7 +322,7 @@ def test_connect_ports(
elaboratable_wrapper: ElaboratableWrapper,
nested_signature_mapping: SignalMapping,
elaboratable: Elaboratable,
interface_connections: list[tuple[Signal, Signal]],
interface_connections: List[Tuple[Signal, Signal]],
) -> None:
conns_test = sorted(
elaboratable_wrapper._connect_ports(nested_signature_mapping, elaboratable),
Expand Down

0 comments on commit 5e40dfd

Please sign in to comment.