Skip to content

Commit 7f9600d

Browse files
authored
chore: Use specific rule codes when ignoring type issues (#302)
- Rm ignore of PGH003 rule and update type ignores to be specific. - Rm the comment about deps in the pyprojtoml, as it is obvious now probably.
1 parent 167a902 commit 7f9600d

File tree

8 files changed

+22
-24
lines changed

8 files changed

+22
-24
lines changed

pyproject.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ keywords = [
3838
"Issue Tracker" = "https://github.com/apify/apify-client-python/issues"
3939
"Repository" = "https://github.com/apify/apify-client-python"
4040

41-
# We use inclusive ordered comparison clauses for external packages intentionally in order to enhance SDK's
42-
# compatibility with external packages. This decision was discussed in detail in the following PR:
43-
# https://github.com/apify/apify-sdk-python/pull/154.
4441
[tool.poetry.dependencies]
4542
python = "^3.9"
4643
apify-shared = ">=1.1.2"
@@ -82,7 +79,6 @@ ignore = [
8279
"G004", # Logging statement uses f-string
8380
"ISC001", # This rule may cause conflicts when used with the formatter
8481
"FIX", # flake8-fixme
85-
"PGH003", # Use specific rule codes when ignoring type issues
8682
"PLR0911", # Too many return statements
8783
"PLR0913", # Too many arguments in function definition
8884
"PLR0915", # Too many statements
@@ -161,15 +157,17 @@ warn_unreachable = true
161157
warn_unused_ignores = true
162158
exclude = []
163159

160+
[tool.basedpyright]
161+
pythonVersion = "3.9"
162+
typeCheckingMode = "standard"
163+
include = ["scripts", "src", "tests"]
164+
164165
[tool.coverage.report]
165166
exclude_lines = [
166167
"pragma: no cover",
167168
"if TYPE_CHECKING:",
168169
"assert_never()",
169170
]
170171

171-
[tool.basedpyright]
172-
typeCheckingMode = "standard"
173-
174172
[tool.ipdb]
175173
context = 7

scripts/check_async_docstrings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
from pathlib import Path
88

9-
from redbaron import RedBaron # type: ignore
9+
from redbaron import RedBaron # type: ignore[import-untyped]
1010
from utils import sync_to_async_docstring
1111

1212
found_issues = False

scripts/fix_async_docstrings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
from pathlib import Path
55

6-
from redbaron import RedBaron # type: ignore
6+
from redbaron import RedBaron # type: ignore[import-untyped]
77
from utils import sync_to_async_docstring
88

99
# Get the directory of the source files

src/apify_client/clients/resource_clients/actor_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def create(
5151
description: str | None = None,
5252
seo_title: str | None = None,
5353
seo_description: str | None = None,
54-
versions: list[dict] | None = None, # type: ignore
54+
versions: list[dict] | None = None, # type: ignore[valid-type]
5555
restart_on_error: bool | None = None,
5656
is_public: bool | None = None,
5757
is_deprecated: bool | None = None,
5858
is_anonymously_runnable: bool | None = None,
59-
categories: list[str] | None = None, # type: ignore
59+
categories: list[str] | None = None, # type: ignore[valid-type]
6060
default_run_build: str | None = None,
6161
default_run_max_items: int | None = None,
6262
default_run_memory_mbytes: int | None = None,
@@ -173,12 +173,12 @@ async def create(
173173
description: str | None = None,
174174
seo_title: str | None = None,
175175
seo_description: str | None = None,
176-
versions: list[dict] | None = None, # type: ignore
176+
versions: list[dict] | None = None, # type: ignore[valid-type]
177177
restart_on_error: bool | None = None,
178178
is_public: bool | None = None,
179179
is_deprecated: bool | None = None,
180180
is_anonymously_runnable: bool | None = None,
181-
categories: list[str] | None = None, # type: ignore
181+
categories: list[str] | None = None, # type: ignore[valid-type]
182182
default_run_build: str | None = None,
183183
default_run_max_items: int | None = None,
184184
default_run_memory_mbytes: int | None = None,

src/apify_client/clients/resource_clients/actor_version_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def create(
3636
*,
3737
version_number: str,
3838
build_tag: str | None = None,
39-
env_vars: list[dict] | None = None, # type: ignore
39+
env_vars: list[dict] | None = None, # type: ignore[valid-type]
4040
apply_env_vars_to_build: bool | None = None,
4141
source_type: ActorSourceType,
42-
source_files: list[dict] | None = None, # type: ignore
42+
source_files: list[dict] | None = None, # type: ignore[valid-type]
4343
git_repo_url: str | None = None,
4444
tarball_url: str | None = None,
4545
github_gist_url: str | None = None,
@@ -107,10 +107,10 @@ async def create(
107107
*,
108108
version_number: str,
109109
build_tag: str | None = None,
110-
env_vars: list[dict] | None = None, # type: ignore
110+
env_vars: list[dict] | None = None, # type: ignore[valid-type]
111111
apply_env_vars_to_build: bool | None = None,
112112
source_type: ActorSourceType,
113-
source_files: list[dict] | None = None, # type: ignore
113+
source_files: list[dict] | None = None, # type: ignore[valid-type]
114114
git_repo_url: str | None = None,
115115
tarball_url: str | None = None,
116116
github_gist_url: str | None = None,

src/apify_client/clients/resource_clients/key_value_store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_record(self: KeyValueStoreClient, key: str, *, as_bytes: bool = False, a
110110
DeprecationWarning,
111111
stacklevel=2,
112112
)
113-
return self.stream_record(key) # type: ignore
113+
return self.stream_record(key) # type: ignore[return-value]
114114

115115
response = self.http_client.call(
116116
url=self._url(f'records/{key}'),
@@ -120,7 +120,7 @@ def get_record(self: KeyValueStoreClient, key: str, *, as_bytes: bool = False, a
120120

121121
return {
122122
'key': key,
123-
'value': response._maybe_parsed_body, # type: ignore # noqa: SLF001
123+
'value': response._maybe_parsed_body, # type: ignore[attr-defined] # noqa: SLF001
124124
'content_type': response.headers['content-type'],
125125
}
126126

@@ -323,7 +323,7 @@ async def get_record(self: KeyValueStoreClientAsync, key: str) -> dict | None:
323323

324324
return {
325325
'key': key,
326-
'value': response._maybe_parsed_body, # type: ignore # noqa: SLF001
326+
'value': response._maybe_parsed_body, # type: ignore[attr-defined] # noqa: SLF001
327327
'content_type': response.headers['content-type'],
328328
}
329329

src/apify_client/clients/resource_clients/schedule_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def create(
4848
is_enabled: bool,
4949
is_exclusive: bool,
5050
name: str | None = None,
51-
actions: list[dict] | None = None, # type: ignore
51+
actions: list[dict] | None = None, # type: ignore[valid-type]
5252
description: str | None = None,
5353
timezone: str | None = None,
5454
title: str | None = None,
@@ -125,7 +125,7 @@ async def create(
125125
is_enabled: bool,
126126
is_exclusive: bool,
127127
name: str | None = None,
128-
actions: list[dict] | None = None, # type: ignore
128+
actions: list[dict] | None = None, # type: ignore[valid-type]
129129
description: str | None = None,
130130
timezone: str | None = None,
131131
title: str | None = None,

src/apify_client/clients/resource_clients/webhook_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def list(
4545
def create(
4646
self: WebhookCollectionClient,
4747
*,
48-
event_types: list[WebhookEventType], # type: ignore
48+
event_types: list[WebhookEventType], # type: ignore[valid-type]
4949
request_url: str,
5050
payload_template: str | None = None,
5151
headers_template: str | None = None,
@@ -132,7 +132,7 @@ async def list(
132132
async def create(
133133
self: WebhookCollectionClientAsync,
134134
*,
135-
event_types: list[WebhookEventType], # type: ignore
135+
event_types: list[WebhookEventType], # type: ignore[valid-type]
136136
request_url: str,
137137
payload_template: str | None = None,
138138
headers_template: str | None = None,

0 commit comments

Comments
 (0)