From 98f36692c77da09d9de1c0864c163de577a08cd1 Mon Sep 17 00:00:00 2001 From: wevsty Date: Thu, 17 Jun 2021 01:13:43 +0800 Subject: [PATCH] fix convert_unspecified_to_localhost pytype check error Fix tab to space --- aiosmtpd/controller.py | 7 ++++--- setup.cfg | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/aiosmtpd/controller.py b/aiosmtpd/controller.py index 46c39978..6d2837c7 100644 --- a/aiosmtpd/controller.py +++ b/aiosmtpd/controller.py @@ -88,13 +88,14 @@ def is_unspecified_address(address: str) -> bool: @public def convert_unspecified_to_localhost( address: str -) -> Literal["::1", "127.0.0.1"]: +) -> str: + localhost = get_localhost() address_dict = { - "": get_localhost(), + "": localhost, "0.0.0.0": "127.0.0.1", # nosec "::": "::1", # nosec } - return address_dict.get(address, get_localhost()) + return str(address_dict.get(address, localhost)) class _FakeServer(asyncio.StreamReaderProtocol): diff --git a/setup.cfg b/setup.cfg index 431b2679..974ea7e9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -73,8 +73,8 @@ ignore = # black conflicts with E123 & E133 E123 E133 - # E261 conflicts with bandit ignore syntax - E261 + # E261 conflicts with bandit ignore syntax + E261 # W503 conflicts with PEP8... W503 # W293 is a bit too noisy. Many files have been edited using editors that do not remove spaces from blank lines. @@ -83,16 +83,16 @@ ignore = E203 # Sometimes we prefer the func()-based creation, not literal, for readability C408 - # Keeping variable names helps to understand the code - PIE781 + # Keeping variable names helps to understand the code + PIE781 # Sometimes we need to catch Exception broadly PIE786 - # Custom type required - PIE795 - # Some classes need to be used for inheritance and are not unnecessary - PIE798 - # Some data must be inserted and cannot be pre-initialized - PIE799 + # Custom type required + PIE795 + # Some classes need to be used for inheritance and are not unnecessary + PIE798 + # Some data must be inserted and cannot be pre-initialized + PIE799 # We don't really care about pytest.fixture vs pytest.fixture() PT001 # Good idea, but too many changes. Remove this in the future, and create separate PR @@ -107,8 +107,8 @@ ignore = ANN003 # We have too many "if..elif..else: raise" structures that does not convert well to "error-first" design SIM106 - # Dataclasses were introduced with PEP 557 in Python 3.7 but we need support 3.6 - SIM119 + # Dataclasses were introduced with PEP 557 in Python 3.7 but we need support 3.6 + SIM119 per-file-ignores = aiosmtpd/tests/test_*:ANN001 aiosmtpd/tests/test_proxyprotocol.py:DUO102