Verified Commit c079c41f authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Remove all references to typing.Any

parent f7582242
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
#  Copyright 2019-2021  Dom Sekotill <dom.sekotill@kodo.org.uk>
#  Copyright 2019-2021, 2024  Dom Sekotill <dom.sekotill@kodo.org.uk>
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
@@ -18,9 +18,8 @@ Anyio helpers for unit tests

import sys
from functools import wraps
from typing import Any
from typing import Awaitable
from typing import Callable
from typing import Coroutine
from typing import Literal
from typing import Tuple
from typing import Union
@@ -40,7 +39,7 @@ Backend = Union[Literal['asyncio'], Literal['trio']]

py_version = sys.version_info[:2]

AsyncTestFunc = Callable[..., Coroutine[Any, Any, None]]
AsyncTestFunc = Callable[..., Awaitable[None]]
TestFunc = Callable[..., None]


@@ -77,11 +76,11 @@ class AsyncMock(mock.Mock):
	A Mock class that acts as a coroutine when called
	"""

	def __init__(self, *args: Any, delay: float = 0.0, **kwargs: Any):
	def __init__(self, *args: object, delay: float = 0.0, **kwargs: object):
		mock._safe_super(AsyncMock, self).__init__(*args, **kwargs)  # type: ignore
		self.delay = delay

	async def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any:
	async def __call__(_mock_self, *args: object, **kwargs: object) -> object:
		_mock_self._mock_check_sig(*args, **kwargs)
		if py_version >= (3, 8):
			_mock_self._increment_mock_call(*args, **kwargs)
+2 −3
Original line number Diff line number Diff line
@@ -24,16 +24,15 @@ import socket
import tempfile
from contextlib import suppress
from os import PathLike
from typing import Any
from typing import Awaitable
from typing import Callable
from typing import Coroutine
from typing import Dict
from typing import Protocol
from typing import Union

import sniffio

ConnectorFn = Callable[[str, str], Coroutine[Any, Any, 'DatagramSocket']]
ConnectorFn = Callable[[str, str], Awaitable['DatagramSocket']]

connectors: Dict[str, ConnectorFn] = {}

+4 −5
Original line number Diff line number Diff line
#  Copyright 2019-2021  Dom Sekotill <dom.sekotill@kodo.org.uk>
#  Copyright 2019-2021, 2024  Dom Sekotill <dom.sekotill@kodo.org.uk>
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ import logging
import os
from re import compile as regex
from types import TracebackType as Traceback
from typing import Any
from typing import AsyncContextManager
from typing import Callable
from typing import Dict
@@ -295,12 +294,12 @@ class BaseClient:
				await client.send_command(consts.COMMAND_ATTACH)
			client._eventcount += 1

		async def __aexit__(self, *exc_info: Any) -> None:
		async def __aexit__(self, exc_type: type[BaseException]|None, *exc_info: object) -> None:
			client = self.client
			assert client._eventcount > 0
			client._eventcount -= 1
			if client._eventcount == 0:
				if __debug__:  # On it's own for compiler optimisation
					if exc_info[0]:
						client.logger.debug(f"Detaching due to {exc_info[0].__name__}")
					if exc_type:
						client.logger.debug(f"Detaching due to {exc_type.__name__}")
				await client.send_command(consts.COMMAND_DETACH)
+2 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ from __future__ import annotations

from itertools import count
from os import PathLike
from typing import Any
from typing import AsyncGenerator
from typing import Dict

@@ -59,7 +58,7 @@ class InterfaceClient(BaseClient):
					return
				yield bss

	async def add_network(self, configuration: Dict[str, Any]) -> int:
	async def add_network(self, configuration: Dict[str, object]) -> int:
		"""Add a new network configuration"""
		netid = await self.send_command(consts.COMMAND_ADD_NETWORK, convert=str)
		for var, val in configuration.items():
@@ -67,7 +66,7 @@ class InterfaceClient(BaseClient):
		await self.send_command(consts.COMMAND_ENABLE_NETWORK, netid)
		return int(netid)

	async def set_network(self, netid: str, variable: str, value: Any) -> None:
	async def set_network(self, netid: str, variable: str, value: object) -> None:
		"""Set a network configuration option"""
		if not isinstance(value, config.get_type(variable)):
			raise TypeError(f"Wrong type for {variable}: {value!r}")
+3 −4
Original line number Diff line number Diff line
#  Copyright 2019-2021  Dom Sekotill <dom.sekotill@kodo.org.uk>
#  Copyright 2019-2021, 2024  Dom Sekotill <dom.sekotill@kodo.org.uk>
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ Helpers for network configuration

from enum import Enum
from enum import auto
from typing import Any
from typing import Callable
from typing import Dict
from typing import Optional
@@ -67,7 +66,7 @@ def get_type(variable: str) -> type:


class _UnknownTypeMeta(type):
	def __instancecheck__(cls, instance: Any) -> bool:
	def __instancecheck__(cls, instance: object) -> bool:
		return isinstance(instance, (str, int))


@@ -82,7 +81,7 @@ class ConfigEnum(Enum):
		return str(self.value)

	@staticmethod
	def _generate_next_value_(name: str, *_: Any) -> str:
	def _generate_next_value_(name: str, *_: object) -> str:
		return name.replace("_", "-")