Prefer Mapping arguments and Dict return types

Replace all use of Mapping return types with Dict, which is the more
concrete type. Replace most use of Dict argument types with Mapping,
where possible.

"Note that to annotate arguments, it is preferred to use an abstract
c ollection type such as Mapping rather than to use dict or typing.Dict."

See https://docs.python.org/3/library/typing.html#typing.Dict

Bug: b/285950835
Change-Id: I100130d7471643b4964cd18a4c099188c3f8a76f
Reviewed-on: https://fuchsia-review.googlesource.com/c/antlion/+/885954
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Sam Balana <sbalana@google.com>
Reviewed-by: Patrick Lu <patricklu@google.com>
diff --git a/packages/antlion/capabilities/ssh.py b/packages/antlion/capabilities/ssh.py
index 1750a7e..4e99b71 100644
--- a/packages/antlion/capabilities/ssh.py
+++ b/packages/antlion/capabilities/ssh.py
@@ -18,7 +18,7 @@
 import subprocess
 import time
 from dataclasses import dataclass
-from typing import Any, BinaryIO, Dict, List, Optional, Union
+from typing import Any, BinaryIO, List, Mapping, Optional, Union
 
 from antlion import logger, signals
 from antlion.net import wait_for_port
@@ -153,7 +153,7 @@
         )
 
     @staticmethod
-    def from_config(config: Dict[str, Any]) -> "SSHConfig":
+    def from_config(config: Mapping[str, Any]) -> "SSHConfig":
         ssh_binary_path = config.get("ssh_binary_path", None)
         if ssh_binary_path is None:
             ssh_binary_path = shutil.which("ssh")
diff --git a/packages/antlion/controllers/access_point.py b/packages/antlion/controllers/access_point.py
index da8a0d8..7fc882c 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, Dict, FrozenSet, List, Optional, Set, Tuple
+from typing import Any, Dict, FrozenSet, List, Mapping, Optional, Set, Tuple
 
 from antlion import logger, utils
 from antlion.capabilities.ssh import SSHConfig, SSHProvider
@@ -75,7 +75,7 @@
         dhcp_settings: The dhcp server settings being used.
     """
 
-    def __init__(self, configs: Dict[str, Any]) -> None:
+    def __init__(self, configs: Mapping[str, Any]) -> None:
         """
         Args:
             configs: configs for the access point from config file.
@@ -674,12 +674,12 @@
         self.log.info("Power cycled successfully")
 
         for settings in hostapd_configs:
-            if type(settings) == HostapdConfig:
+            if isinstance(settings, HostapdConfig):
                 config = settings
                 setup_bridge = False
-                additional_parameters = {}
+                additional_parameters: Dict[str, Any] = {}
 
-            elif type(settings) == dict:
+            elif isinstance(settings, dict):
                 config = settings["hostapd_config"]
                 setup_bridge = settings.get("setup_bridge", False)
                 additional_parameters = settings.get("additional_parameters", {})
diff --git a/packages/antlion/controllers/ap_lib/regulatory_channels.py b/packages/antlion/controllers/ap_lib/regulatory_channels.py
index 3539d40..8c35858 100644
--- a/packages/antlion/controllers/ap_lib/regulatory_channels.py
+++ b/packages/antlion/controllers/ap_lib/regulatory_channels.py
@@ -1,11 +1,11 @@
 from dataclasses import dataclass
-from typing import List, Mapping
+from typing import Dict, List
 
 Channel = int
 Bandwidth = int
 # TODO(http://b/281728764): Add device requirements to each frequency e.g.
 # "MUST be used indoors only" or "MUST be used with DFS".
-ChannelBandwidthMap = Mapping[Channel, List[Bandwidth]]
+ChannelBandwidthMap = Dict[Channel, List[Bandwidth]]
 
 
 @dataclass
diff --git a/packages/antlion/controllers/fuchsia_device.py b/packages/antlion/controllers/fuchsia_device.py
index 8632aeb..0914f6e 100644
--- a/packages/antlion/controllers/fuchsia_device.py
+++ b/packages/antlion/controllers/fuchsia_device.py
@@ -20,7 +20,7 @@
 import subprocess
 import textwrap
 import time
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List, Mapping, Optional
 
 from antlion import context
 from antlion import logger as acts_logger
@@ -160,7 +160,7 @@
         ssh_config: The ssh_config for connecting to the Fuchsia device.
     """
 
-    def __init__(self, fd_conf_data: Dict[str, Any]) -> None:
+    def __init__(self, fd_conf_data: Mapping[str, Any]) -> None:
         self.conf_data = fd_conf_data
         if "ip" not in fd_conf_data:
             raise FuchsiaDeviceError(FUCHSIA_DEVICE_NO_IP_MSG)
diff --git a/packages/antlion/controllers/fuchsia_lib/base_lib.py b/packages/antlion/controllers/fuchsia_lib/base_lib.py
index bbd3bf2..cc0ba34 100644
--- a/packages/antlion/controllers/fuchsia_lib/base_lib.py
+++ b/packages/antlion/controllers/fuchsia_lib/base_lib.py
@@ -16,7 +16,7 @@
 
 import json
 import socket
-from typing import Any, Mapping
+from typing import Any, Dict, Mapping
 from urllib.request import Request, urlopen
 
 from antlion import logger
@@ -44,7 +44,7 @@
         cmd: str,
         args: Mapping[str, Any],
         response_timeout: int = DEFAULT_SL4F_RESPONSE_TIMEOUT_SEC,
-    ) -> Mapping[str, Any]:
+    ) -> Dict[str, Any]:
         """Builds and sends a JSON command to SL4F server.
 
         Args:
diff --git a/packages/antlion/controllers/fuchsia_lib/device_lib.py b/packages/antlion/controllers/fuchsia_lib/device_lib.py
index c448c0c..b5b560e 100644
--- a/packages/antlion/controllers/fuchsia_lib/device_lib.py
+++ b/packages/antlion/controllers/fuchsia_lib/device_lib.py
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Any, Mapping
+from typing import Any, Dict
 
 from antlion.controllers.fuchsia_lib.base_lib import BaseLib
 
@@ -23,17 +23,17 @@
     def __init__(self, addr: str) -> None:
         super().__init__(addr, "device")
 
-    def get_device_name(self) -> Mapping[str, Any]:
+    def get_device_name(self) -> Dict[str, Any]:
         """Get the device name."""
 
         return self.send_command("device_facade.GetDeviceName", {})
 
-    def get_product_name(self) -> Mapping[str, Any]:
+    def get_product_name(self) -> Dict[str, Any]:
         """Get the product name."""
 
         return self.send_command("device_facade.GetProduct", {})
 
-    def get_version(self) -> Mapping[str, Any]:
+    def get_version(self) -> Dict[str, Any]:
         """Get the device version."""
 
         return self.send_command("device_facade.GetVersion", {})
diff --git a/packages/antlion/controllers/fuchsia_lib/ffx.py b/packages/antlion/controllers/fuchsia_lib/ffx.py
index 3bcbbfc..9b229c2 100644
--- a/packages/antlion/controllers/fuchsia_lib/ffx.py
+++ b/packages/antlion/controllers/fuchsia_lib/ffx.py
@@ -21,7 +21,7 @@
 import time
 from pathlib import Path, PurePath
 from shutil import rmtree
-from typing import Any, MutableMapping, Optional
+from typing import Any, Dict, Optional
 
 from antlion import context, logger, signals, utils
 
@@ -177,7 +177,7 @@
         self._ssh_auth_sock_path = str(PurePath(self._sock_dir, "ssh_auth_sock"))
         self._overnet_socket_path = str(PurePath(self._sock_dir, "overnet_socket"))
 
-        config: MutableMapping[str, Any] = {
+        config: Dict[str, Any] = {
             "target": {
                 "default": self.mdns_name,
             },
diff --git a/packages/antlion/controllers/utils_lib/ssh/settings.py b/packages/antlion/controllers/utils_lib/ssh/settings.py
index 4a2bd10..f925145 100644
--- a/packages/antlion/controllers/utils_lib/ssh/settings.py
+++ b/packages/antlion/controllers/utils_lib/ssh/settings.py
@@ -20,7 +20,7 @@
     An instance of SshSettings or None
 """
 
-from typing import Dict, Optional, Union
+from typing import Dict, Mapping, Optional, Union
 
 
 class SshSettings(object):
@@ -98,7 +98,7 @@
         return current_flags
 
 
-def from_config(config: Dict[str, Union[str, int]]) -> SshSettings:
+def from_config(config: Mapping[str, Union[str, int]]) -> SshSettings:
     ssh_binary_path = config.get("ssh_binary_path", "/usr/bin/ssh")
     if type(ssh_binary_path) != str:
         raise ValueError(f"ssh_binary_path must be a string, got {ssh_binary_path}")
diff --git a/packages/antlion/test_utils/abstract_devices/wmm_transceiver.py b/packages/antlion/test_utils/abstract_devices/wmm_transceiver.py
index 0f21908..77e5531 100644
--- a/packages/antlion/test_utils/abstract_devices/wmm_transceiver.py
+++ b/packages/antlion/test_utils/abstract_devices/wmm_transceiver.py
@@ -19,7 +19,7 @@
 import time
 from datetime import datetime
 from multiprocessing.managers import DictProxy
-from typing import Any, Dict, List, Optional
+from typing import Any, List, Mapping, Optional
 from uuid import UUID, uuid4
 
 from antlion import signals, tracelogger, utils
@@ -51,7 +51,7 @@
 
 
 def create(
-    config: Dict[str, Any],
+    config: Mapping[str, Any],
     identifier: Optional[str] = None,
     wlan_devices: Optional[List[SupportsWLAN]] = None,
     access_points: Optional[List[AccessPoint]] = None,