Remove use of typing.Tuple
Replace all use of typing.Tuple with its equivalent Python collection,
tuple. This syntax was introduced with Python 3.9.
Change-Id: I7ab2dd128dc4ec08a1c2090a57e04411e9206766
Reviewed-on: https://fuchsia-review.googlesource.com/c/antlion/+/890275
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Hayden Nix <haydennix@google.com>
Fuchsia-Auto-Submit: Sam Balana <sbalana@google.com>
diff --git a/packages/antlion/base_test.py b/packages/antlion/base_test.py
index 2035416..25e7cac 100755
--- a/packages/antlion/base_test.py
+++ b/packages/antlion/base_test.py
@@ -23,7 +23,7 @@
import re
import traceback
from concurrent.futures import ThreadPoolExecutor
-from typing import Callable, Tuple
+from typing import Callable
from mobly import asserts
from mobly.base_test import BaseTestClass as MoblyBaseTest
@@ -978,7 +978,7 @@
# functionality is merged into Mobly.
def _get_test_methods(
self, test_names: list[str]
- ) -> list[Tuple[str, Callable[[], None]]]:
+ ) -> list[tuple[str, Callable[[], None]]]:
"""Resolves test method names to bound test methods.
Args:
@@ -997,7 +997,7 @@
if name.startswith("test_"):
test_table[name] = getattr(self, name)
- test_methods: list[Tuple[str, Callable[[], None]]] = []
+ test_methods: list[tuple[str, Callable[[], None]]] = []
for test_name in test_names:
if test_name in test_table:
test_methods.append((test_name, test_table[test_name]))
diff --git a/packages/antlion/controllers/access_point.py b/packages/antlion/controllers/access_point.py
index 0db1411..c32901f 100755
--- a/packages/antlion/controllers/access_point.py
+++ b/packages/antlion/controllers/access_point.py
@@ -17,7 +17,7 @@
import ipaddress
import time
from dataclasses import dataclass
-from typing import Any, FrozenSet, Mapping, Set, Tuple
+from typing import Any, FrozenSet, Mapping, Set
from antlion import logger, utils
from antlion.capabilities.ssh import SSHConfig, SSHProvider
@@ -558,7 +558,7 @@
self.stop_all_aps()
self.ssh.close()
- def generate_bridge_configs(self, channel: int) -> Tuple[str, str | None, str]:
+ def generate_bridge_configs(self, channel: int) -> tuple[str, str | None, str]:
"""Generate a list of configs for a bridge between LAN and WLAN.
Args:
diff --git a/packages/antlion/controllers/ap_lib/ap_get_interface.py b/packages/antlion/controllers/ap_lib/ap_get_interface.py
index b7701ab..7836644 100644
--- a/packages/antlion/controllers/ap_lib/ap_get_interface.py
+++ b/packages/antlion/controllers/ap_lib/ap_get_interface.py
@@ -15,7 +15,7 @@
# limitations under the License.
import logging
-from typing import TYPE_CHECKING, Tuple
+from typing import TYPE_CHECKING
from antlion.libs.proc import job
@@ -104,7 +104,7 @@
interfaces_bridge.pop(0)
return [x for x in interfaces_bridge if x != ""]
- def get_wlan_interface(self) -> Tuple[str, str]:
+ def get_wlan_interface(self) -> tuple[str, str]:
"""Get all WLAN interfaces and specify 2.4 GHz and 5 GHz interfaces.
Returns:
diff --git a/packages/antlion/controllers/ap_lib/extended_capabilities.py b/packages/antlion/controllers/ap_lib/extended_capabilities.py
index f44f621..4570409 100644
--- a/packages/antlion/controllers/ap_lib/extended_capabilities.py
+++ b/packages/antlion/controllers/ap_lib/extended_capabilities.py
@@ -15,7 +15,6 @@
# limitations under the License.
from enum import IntEnum, unique
-from typing import Tuple
@unique
@@ -119,7 +118,7 @@
# 88-n reserved
-def _offsets(ext_cap_offset: ExtendedCapability) -> Tuple[int, int]:
+def _offsets(ext_cap_offset: ExtendedCapability) -> tuple[int, int]:
"""For given capability, return the byte and bit offsets within the field.
802.11 divides the extended capability field into bytes, as does the
diff --git a/packages/antlion/controllers/ap_lib/hostapd_constants.py b/packages/antlion/controllers/ap_lib/hostapd_constants.py
index 3ec979b..4476f8f 100755
--- a/packages/antlion/controllers/ap_lib/hostapd_constants.py
+++ b/packages/antlion/controllers/ap_lib/hostapd_constants.py
@@ -16,7 +16,7 @@
import itertools
from enum import Enum, auto, unique
-from typing import Tuple, TypedDict
+from typing import TypedDict
BAND_2G = "2g"
BAND_5G = "5g"
@@ -374,7 +374,7 @@
class VHTChannelWidth(TypedDict):
delta: int
- channels: list[Tuple[int, int]]
+ channels: list[tuple[int, int]]
CENTER_CHANNEL_MAP = {
diff --git a/packages/antlion/controllers/fuchsia_lib/lib_controllers/wlan_policy_controller.py b/packages/antlion/controllers/fuchsia_lib/lib_controllers/wlan_policy_controller.py
index 676a206..0b69408 100644
--- a/packages/antlion/controllers/fuchsia_lib/lib_controllers/wlan_policy_controller.py
+++ b/packages/antlion/controllers/fuchsia_lib/lib_controllers/wlan_policy_controller.py
@@ -17,7 +17,7 @@
import multiprocessing
import time
from dataclasses import dataclass
-from typing import Any, Tuple
+from typing import Any
from antlion import logger, signals
from antlion.controllers.ap_lib.hostapd_security import FuchsiaSecurityType
@@ -56,7 +56,7 @@
id: str
-def get_country_code_from_phy(params: GetCountryCodeFromPhyParams) -> Tuple[str, str]:
+def get_country_code_from_phy(params: GetCountryCodeFromPhyParams) -> tuple[str, str]:
get_country_response = params.wlan_lib.wlanGetCountry(params.id)
if get_country_response.get("error"):
raise ConnectionError(
diff --git a/stubs/mobly/utils.pyi b/stubs/mobly/utils.pyi
index 45ae2a3..7024b47 100644
--- a/stubs/mobly/utils.pyi
+++ b/stubs/mobly/utils.pyi
@@ -1,7 +1,4 @@
-from typing import Tuple, overload
-
from _typeshed import Incomplete
-from typing_extensions import Literal
MAX_FILENAME_LEN: int
MAX_PORT_ALLOCATION_RETRY: int
@@ -34,7 +31,7 @@
cwd=...,
env=...,
universal_newlines: bool = ...,
-) -> Tuple[int, bytes, bytes] | Tuple[int, str, str]: ...
+) -> tuple[int, bytes, bytes] | tuple[int, str, str]: ...
def start_standing_subprocess(cmd, shell: bool = ..., env: Incomplete | None = ...): ...
def stop_standing_subprocess(proc) -> None: ...
def wait_for_standing_subprocess(proc, timeout: Incomplete | None = ...) -> None: ...
diff --git a/tests/wlan/compliance/WlanPhyCompliance11ACTest.py b/tests/wlan/compliance/WlanPhyCompliance11ACTest.py
index fb3bb4f..618d1e7 100644
--- a/tests/wlan/compliance/WlanPhyCompliance11ACTest.py
+++ b/tests/wlan/compliance/WlanPhyCompliance11ACTest.py
@@ -17,7 +17,7 @@
import itertools
import logging
from dataclasses import dataclass
-from typing import Any, Tuple
+from typing import Any
from mobly import asserts, signals, test_runner
from mobly.records import TestResultRecord
@@ -120,7 +120,7 @@
super().__init__(controllers)
def setup_generated_tests(self):
- test_args: list[Tuple[TestParams]] = (
+ test_args: list[tuple[TestParams]] = (
self._generate_20mhz_test_args()
+ self._generate_40mhz_test_args()
+ self._generate_80mhz_test_args()
@@ -217,8 +217,8 @@
)
# 1728 tests
- def _generate_20mhz_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_20mhz_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
# 864 test cases for open security
# 864 test cases for wpa2 security
@@ -246,8 +246,8 @@
return test_args
# 1728 tests
- def _generate_40mhz_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_40mhz_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
# 864 test cases for open security
# 864 test cases for wpa2 security
@@ -275,8 +275,8 @@
return test_args
# 3456 tests
- def _generate_80mhz_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_80mhz_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
# 1728 test cases for open security
# 1728 test cases for wpa2 security
diff --git a/tests/wlan/compliance/WlanPhyCompliance11NTest.py b/tests/wlan/compliance/WlanPhyCompliance11NTest.py
index 9e68db5..955b20a 100644
--- a/tests/wlan/compliance/WlanPhyCompliance11NTest.py
+++ b/tests/wlan/compliance/WlanPhyCompliance11NTest.py
@@ -17,7 +17,7 @@
import itertools
import logging
from dataclasses import dataclass
-from typing import Any, Tuple
+from typing import Any
from mobly import asserts, signals, test_runner
from mobly.records import TestResultRecord
@@ -71,7 +71,7 @@
super().__init__(controllers)
def setup_generated_tests(self):
- test_args: list[Tuple[TestParams]] = (
+ test_args: list[tuple[TestParams]] = (
self._generate_24_HT20_test_args()
+ self._generate_24_HT40_lower_test_args()
+ self._generate_24_HT40_upper_test_args()
@@ -224,8 +224,8 @@
"Failed to connect.",
)
- def _generate_24_HT20_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_24_HT20_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_24,
CHANNEL_BANDWIDTH_20,
@@ -251,8 +251,8 @@
)
return test_args
- def _generate_24_HT40_lower_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_24_HT40_lower_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_24,
CHANNEL_BANDWIDTH_40_LOWER,
@@ -278,8 +278,8 @@
)
return test_args
- def _generate_24_HT40_upper_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_24_HT40_upper_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_24,
CHANNEL_BANDWIDTH_40_UPPER,
@@ -305,8 +305,8 @@
)
return test_args
- def _generate_5_HT20_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_5_HT20_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_5,
CHANNEL_BANDWIDTH_20,
@@ -331,8 +331,8 @@
)
return test_args
- def _generate_5_HT40_lower_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_5_HT40_lower_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_5,
CHANNEL_BANDWIDTH_40_LOWER,
@@ -358,8 +358,8 @@
)
return test_args
- def _generate_5_HT40_upper_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_5_HT40_upper_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_5,
CHANNEL_BANDWIDTH_40_UPPER,
@@ -386,8 +386,8 @@
)
return test_args
- def _generate_24_HT20_wpa2_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_24_HT20_wpa2_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_24,
CHANNEL_BANDWIDTH_20,
@@ -412,8 +412,8 @@
)
return test_args
- def _generate_24_HT40_lower_wpa2_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_24_HT40_lower_wpa2_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_24,
CHANNEL_BANDWIDTH_40_LOWER,
@@ -439,8 +439,8 @@
)
return test_args
- def _generate_24_HT40_upper_wpa2_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_24_HT40_upper_wpa2_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_24,
CHANNEL_BANDWIDTH_40_UPPER,
@@ -466,8 +466,8 @@
)
return test_args
- def _generate_5_HT20_wpa2_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_5_HT20_wpa2_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_5,
CHANNEL_BANDWIDTH_20,
@@ -492,8 +492,8 @@
)
return test_args
- def _generate_5_HT40_lower_wpa2_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_5_HT40_lower_wpa2_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_5,
CHANNEL_BANDWIDTH_40_LOWER,
@@ -519,8 +519,8 @@
)
return test_args
- def _generate_5_HT40_upper_wpa2_test_args(self) -> list[Tuple[TestParams]]:
- test_args: list[Tuple[TestParams]] = []
+ def _generate_5_HT40_upper_wpa2_test_args(self) -> list[tuple[TestParams]]:
+ test_args: list[tuple[TestParams]] = []
for combination in itertools.product(
FREQUENCY_5,
CHANNEL_BANDWIDTH_40_UPPER,
diff --git a/tests/wlan/functional/reboot/WlanRebootApTest.py b/tests/wlan/functional/reboot/WlanRebootApTest.py
index 6b2f74b..02fff52 100644
--- a/tests/wlan/functional/reboot/WlanRebootApTest.py
+++ b/tests/wlan/functional/reboot/WlanRebootApTest.py
@@ -15,7 +15,6 @@
# limitations under the License.
import itertools
-from typing import Tuple
import base_test
from base_test import BandType, DeviceType, IpVersionType, RebootType, TestParams
@@ -40,8 +39,8 @@
arg_sets=self._generate_reboot_ap_test_params(),
)
- def _generate_reboot_ap_test_params(self) -> list[Tuple[TestParams]]:
- test_params: list[Tuple[TestParams]] = []
+ def _generate_reboot_ap_test_params(self) -> list[tuple[TestParams]]:
+ test_params: list[tuple[TestParams]] = []
for (
reboot_type,
band,
diff --git a/tests/wlan/functional/reboot/WlanRebootDutTest.py b/tests/wlan/functional/reboot/WlanRebootDutTest.py
index 0b916a8..185357b 100644
--- a/tests/wlan/functional/reboot/WlanRebootDutTest.py
+++ b/tests/wlan/functional/reboot/WlanRebootDutTest.py
@@ -15,7 +15,6 @@
# limitations under the License.
import itertools
-from typing import Tuple
import base_test
from base_test import BandType, DeviceType, IpVersionType, RebootType, TestParams
@@ -40,8 +39,8 @@
arg_sets=self._generate_reboot_dut_test_params(),
)
- def _generate_reboot_dut_test_params(self) -> list[Tuple[TestParams]]:
- test_params: list[Tuple[TestParams]] = []
+ def _generate_reboot_dut_test_params(self) -> list[tuple[TestParams]]:
+ test_params: list[tuple[TestParams]] = []
for (
reboot_type,
band,
diff --git a/tests/wlan/performance/ChannelSweepTest.py b/tests/wlan/performance/ChannelSweepTest.py
index b8c6912..2029906 100644
--- a/tests/wlan/performance/ChannelSweepTest.py
+++ b/tests/wlan/performance/ChannelSweepTest.py
@@ -20,7 +20,6 @@
from dataclasses import dataclass
from pathlib import Path
from statistics import pstdev
-from typing import Tuple
from mobly import asserts, test_runner
from mobly.config_parser import TestRunConfig
@@ -114,7 +113,7 @@
self.channel_throughput: ChannelThroughputMap = {}
def pre_run(self):
- tests: list[Tuple[TestParams]] = []
+ tests: list[tuple[TestParams]] = []
def generate_test_name(test: TestParams):
return f"test_{test.country_code}_{test.security_mode}_channel_{test.channel}_{test.channel_bandwidth}mhz"