diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index 3f3f921..10962b5 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -2,6 +2,7 @@ import json from pathlib import Path from ipaddress import IPv4Network, IPv4Address, IPv6Network, IPv6Address + import whoisit diff --git a/tests/test_parser.py b/tests/test_parser.py index 470f4db..ef3a94e 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -3,7 +3,9 @@ from pathlib import Path from datetime import datetime from ipaddress import IPv4Network, IPv6Network + from dateutil.tz import tzoffset, tzutc + import whoisit diff --git a/tests/test_query.py b/tests/test_query.py index cc6f175..46163c9 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -3,6 +3,7 @@ import json from pathlib import Path from ipaddress import IPv4Network, IPv4Address, IPv6Network, IPv6Address + import whoisit diff --git a/tools/list_public_tlds_with_rdap_endpoints.py b/tools/list_public_tlds_with_rdap_endpoints.py index 3d1269d..44f9064 100755 --- a/tools/list_public_tlds_with_rdap_endpoints.py +++ b/tools/list_public_tlds_with_rdap_endpoints.py @@ -15,6 +15,7 @@ import requests + import whoisit from whoisit.logger import get_logger from whoisit.errors import UnsupportedError diff --git a/whoisit/bootstrap.py b/whoisit/bootstrap.py index 42aadaf..f87437f 100644 --- a/whoisit/bootstrap.py +++ b/whoisit/bootstrap.py @@ -14,6 +14,7 @@ is_subnet_of, ) + log = get_logger('bootstrap') @@ -417,6 +418,7 @@ def get_rir_name_by_endpoint_url(self, url): class Bootstrap(BaseBootstrap): + def __init__(self, session=None, allow_insecure_ssl=False, do_super_init=True): if do_super_init: BaseBootstrap.__init__(self) @@ -430,6 +432,7 @@ def bootstrap(self, overrides=False, allow_insecure=False): class BootstrapAsync(BaseBootstrap): + def __init__(self, client=None, allow_insecure_ssl=False, do_super_init=True): if do_super_init: BaseBootstrap.__init__(self) @@ -443,6 +446,7 @@ async def bootstrap_async(self, overrides=False, allow_insecure=False): class _BootstrapMainModule(Bootstrap, BootstrapAsync): + def __init__(self) -> None: Bootstrap.__init__(self, do_super_init=True) BootstrapAsync.__init__(self, do_super_init=False) diff --git a/whoisit/parser.py b/whoisit/parser.py index d6ee854..5b40b61 100644 --- a/whoisit/parser.py +++ b/whoisit/parser.py @@ -7,10 +7,13 @@ ) from typing import Optional from typing_extensions import TypedDict + from dateutil.parser import parse as dateutil_parse + from .errors import BootstrapError, ParseError from .logger import get_logger + log = get_logger('parser') diff --git a/whoisit/query.py b/whoisit/query.py index 25798f9..c050498 100644 --- a/whoisit/query.py +++ b/whoisit/query.py @@ -27,6 +27,7 @@ from .logger import get_logger from .utils import contains_only_chars, http_request, http_request_async + log = get_logger('query') @@ -221,6 +222,7 @@ def _process_response(self, response): except (TypeError, ValueError) as e: raise QueryError(f'Failed to parse RDAP Query response as JSON: {e}') from e + class Query(BaseQuery): """ Make an HTTP request to an RDAP endpoint as a query. This is slightly more @@ -237,9 +239,10 @@ def request(self, *args, **kwargs): response = http_request(self.session, url=self.url, method=self.method, *args, **kwargs) return self._process_response(response) + class QueryAsync(BaseQuery): """ - Make an Async HTTP request to an RDAP endpoint as a query. This is slightly more + Make an async HTTP request to an RDAP endpoint as a query. This is slightly more elaborate than a single function just to allow kwargs to be arbitrarily passed to both requests and the requested URL if required. """ diff --git a/whoisit/utils.py b/whoisit/utils.py index 8a75c12..097f850 100644 --- a/whoisit/utils.py +++ b/whoisit/utils.py @@ -13,6 +13,7 @@ from .logger import get_logger from .version import version + log = get_logger('utils') user_agent = 'whoisit/{version}' insecure_ssl_ciphers = 'ALL:@SECLEVEL=1' @@ -88,6 +89,7 @@ def create_session(allow_insecure_ssl=False): session.mount('https://', InsecureSSLAdapter()) return session + def create_async_client(allow_insecure_ssl=False): limits = httpx.Limits(max_connections=async_http_max_connections, max_keepalive_connections=async_max_keepalive_connections) retries = httpx.AsyncHTTPTransport(retries=http_max_retries, limits=limits)