pass mypy strict on the new module

This commit is contained in:
Jean-Paul Calderone 2023-03-29 10:00:38 -04:00
parent e8bcfea4f3
commit 2f3091a065
3 changed files with 9 additions and 13 deletions

View File

@ -9,7 +9,7 @@ no_implicit_optional = True
warn_redundant_casts = True
strict_equality = True
[mypy-allmydata.test.cli.wormholetesting]
[mypy-allmydata.test.cli.wormholetesting,allmydata.listeners]
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True

View File

@ -6,7 +6,7 @@ detect when it is possible to use it, etc.
from __future__ import annotations
from typing import Any, Protocol, Sequence, Mapping, Optional
from typing import Any, Protocol, Sequence, Mapping, Optional, Union, Awaitable
from typing_extensions import Literal
from attrs import frozen, define
@ -101,7 +101,7 @@ class StaticProvider:
"""
_available: bool
_hide_ip: bool
_config: Any
_config: Union[Awaitable[ListenerConfig], ListenerConfig]
_address: IAddressFamily
def is_available(self) -> bool:
@ -110,7 +110,9 @@ class StaticProvider:
def can_hide_ip(self) -> bool:
return self._hide_ip
async def create_config(self, reactor: Any, cli_config: Any) -> None:
async def create_config(self, reactor: Any, cli_config: Any) -> ListenerConfig:
if isinstance(self._config, ListenerConfig):
return self._config
return await self._config
def create(self, reactor: Any, config: Any) -> IAddressFamily:

View File

@ -1,17 +1,10 @@
"""
Utilities for getting IP addresses.
Ported to Python 3.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from future.utils import native_str
from future.utils import PY2, native_str
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from typing import Callable
import os, socket
@ -39,6 +32,7 @@ from .gcutil import (
fcntl = requireModule("fcntl")
allocate_tcp_port: Callable[[], int]
from foolscap.util import allocate_tcp_port # re-exported
try: