Skip to content

Commit 1811db9

Browse files
authored
chore: remove self type annotations (#311)
1 parent 5055bdd commit 1811db9

38 files changed

+380
-384
lines changed

src/apify_client/_errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ApifyApiError(ApifyClientError):
1818
"""
1919

2020
@ignore_docs
21-
def __init__(self: ApifyApiError, response: httpx.Response, attempt: int) -> None:
21+
def __init__(self, response: httpx.Response, attempt: int) -> None:
2222
"""Create the ApifyApiError instance.
2323
2424
Args:
@@ -59,7 +59,7 @@ class InvalidResponseBodyError(ApifyClientError):
5959
"""
6060

6161
@ignore_docs
62-
def __init__(self: InvalidResponseBodyError, response: httpx.Response) -> None:
62+
def __init__(self, response: httpx.Response) -> None:
6363
"""Create the InvalidResponseBodyError instance.
6464
6565
Args:

src/apify_client/_http_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class _BaseHTTPClient:
3030
@ignore_docs
3131
def __init__(
32-
self: _BaseHTTPClient,
32+
self,
3333
*,
3434
token: str | None = None,
3535
max_retries: int = 8,
@@ -97,7 +97,7 @@ def _parse_params(params: dict | None) -> dict | None:
9797
return parsed_params
9898

9999
def _prepare_request_call(
100-
self: _BaseHTTPClient,
100+
self,
101101
headers: dict | None = None,
102102
params: dict | None = None,
103103
data: Any = None,
@@ -129,7 +129,7 @@ def _prepare_request_call(
129129

130130
class HTTPClient(_BaseHTTPClient):
131131
def call(
132-
self: HTTPClient,
132+
self,
133133
*,
134134
method: str,
135135
url: str,
@@ -201,7 +201,7 @@ def _make_request(stop_retrying: Callable, attempt: int) -> httpx.Response:
201201

202202
class HTTPClientAsync(_BaseHTTPClient):
203203
async def call(
204-
self: HTTPClientAsync,
204+
self,
205205
*,
206206
method: str,
207207
url: str,

src/apify_client/_logging.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
import logging
77
from contextvars import ContextVar
8-
from typing import TYPE_CHECKING, Any, Callable, NamedTuple, cast
8+
from typing import TYPE_CHECKING, Any, Callable, NamedTuple
99

1010
# Conditional import only executed when type checking, otherwise we'd get circular dependency issues
1111
if TYPE_CHECKING:
@@ -39,12 +39,12 @@ class LogContext(NamedTuple):
3939
# Metaclass for resource clients which wraps all their public methods
4040
# With injection of their details to the log context vars
4141
class WithLogDetailsClient(type):
42-
def __new__(cls: type[type], name: str, bases: tuple, attrs: dict) -> WithLogDetailsClient:
42+
def __new__(cls, name: str, bases: tuple, attrs: dict) -> WithLogDetailsClient:
4343
for attr_name, attr_value in attrs.items():
4444
if not attr_name.startswith('_') and inspect.isfunction(attr_value):
4545
attrs[attr_name] = _injects_client_details_to_log_context(attr_value)
4646

47-
return cast(WithLogDetailsClient, type.__new__(cls, name, bases, attrs))
47+
return type.__new__(cls, name, bases, attrs)
4848

4949

5050
# Wraps an unbound method so that its call will inject the details
@@ -87,7 +87,7 @@ def wrapper(resource_client: _BaseBaseClient, *args: Any, **kwargs: Any) -> Any:
8787
# A filter which lets every log record through,
8888
# but adds the current logging context to the record
8989
class _ContextInjectingFilter(logging.Filter):
90-
def filter(self: _ContextInjectingFilter, record: logging.LogRecord) -> bool:
90+
def filter(self, record: logging.LogRecord) -> bool:
9191
record.client_method = log_context.client_method.get()
9292
record.resource_id = log_context.resource_id.get()
9393
record.method = log_context.method.get()
@@ -105,15 +105,15 @@ class _DebugLogFormatter(logging.Formatter):
105105
empty_record = logging.LogRecord('dummy', 0, 'dummy', 0, 'dummy', None, None)
106106

107107
# Gets the extra fields from the log record which are not present on an empty record
108-
def _get_extra_fields(self: _DebugLogFormatter, record: logging.LogRecord) -> dict:
108+
def _get_extra_fields(self, record: logging.LogRecord) -> dict:
109109
extra_fields: dict = {}
110110
for key, value in record.__dict__.items():
111111
if key not in self.empty_record.__dict__:
112112
extra_fields[key] = value # noqa: PERF403
113113

114114
return extra_fields
115115

116-
def format(self: _DebugLogFormatter, record: logging.LogRecord) -> str:
116+
def format(self, record: logging.LogRecord) -> str:
117117
extra = self._get_extra_fields(record)
118118

119119
log_string = super().format(record)

0 commit comments

Comments
 (0)