Skip to content

Commit 47f790d

Browse files
committed
Disable more pylint checks that are also checked by mypy
pylint has some false positive for these checks, so better to just rely on mypy for them. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 30a5b7f commit 47f790d

File tree

9 files changed

+61
-20
lines changed

9 files changed

+61
-20
lines changed

Diff for: RELEASE_NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* Change `edit_uri` default branch to v0.x.x in mkdocs.yml.
2828
* Added a new default option `asyncio_default_fixture_loop_scope = "function"` for `pytest-asyncio` as not providing a value is deprecated.
2929
* The migration script is now written in Python, so it should be (hopefully) more compatible with different OSes.
30+
* Disable more `pylint` checks that are also checked by `mypy` to avoid false positives.
3031

3132
## Bug Fixes
3233

Diff for: cookiecutter/migrate.py

+39
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,42 @@ def replace_file_contents_atomically( # noqa; DOC501
9292
raise
9393

9494

95+
def add_pylint_checks() -> None:
96+
"""Add new pylint checks to the project."""
97+
pyproject_toml = Path("pyproject.toml")
98+
print(
99+
f"{pyproject_toml}: Skip some flaky pylint checks that are checked better by mypy."
100+
)
101+
marker = ' "no-member",\n'
102+
pyproject_toml_content = pyproject_toml.read_text(encoding="utf-8")
103+
if pyproject_toml_content.find(marker) == -1:
104+
manual_step(
105+
f"""\
106+
{pyproject_toml}: We couldn't find the marker {marker!r} in the file.
107+
Please add the following lines to the file manually in the
108+
`[tool.pylint.messages_control]` section, under the `disable` key (ideally below other
109+
checks that are disabled because `mypy` already checks them) if they are missing:
110+
"no-name-in-module",
111+
"possibly-used-before-assignment",
112+
"""
113+
)
114+
return
115+
116+
replacement = ""
117+
if pyproject_toml_content.find("possibly-used-before-assignment") == -1:
118+
replacement += ' "possibly-used-before-assignment",\n'
119+
if pyproject_toml_content.find("no-name-in-module") == -1:
120+
replacement += ' "no-name-in-module",\n'
121+
122+
if not replacement:
123+
print(f"{pyproject_toml}: seems to be already up-to-date.")
124+
return
125+
126+
replace_file_contents_atomically(
127+
pyproject_toml, marker, marker + replacement, content=pyproject_toml_content
128+
)
129+
130+
95131
def main() -> None:
96132
"""Run the migration steps."""
97133
# Dependabot patch
@@ -128,6 +164,9 @@ def main() -> None:
128164
)
129165
print("=" * 72)
130166

167+
# Add new pylint checks
168+
add_pylint_checks()
169+
131170
# Add a separation line like this one after each migration step.
132171
print("=" * 72)
133172

Diff for: cookiecutter/{{cookiecutter.github_repo_name}}/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ disable = [
178178
# disabled because it conflicts with isort
179179
"wrong-import-order",
180180
"ungrouped-imports",
181-
# pylint's unsubscriptable check is buggy and is not needed because
182-
# it is a type-check, for which we already have mypy.
181+
# Checked by mypy (and pylint is very flaky checking these)
183182
"unsubscriptable-object",
184-
# Checked by mypy
185183
"no-member",
184+
"no-name-in-module",
185+
"possibly-used-before-assignment",
186186
# Checked by flake8
187187
"f-string-without-interpolation",
188188
"line-too-long",

Diff for: pyproject.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ disable = [
161161
# disabled because it conflicts with isort
162162
"wrong-import-order",
163163
"ungrouped-imports",
164-
# pylint's unsubscriptable check is buggy and is not needed because
165-
# it is a type-check, for which we already have mypy.
164+
# Checked by mypy (and pylint is very flaky checking these)
166165
"unsubscriptable-object",
167166
"no-member",
167+
"no-name-in-module",
168+
"possibly-used-before-assignment",
168169
# Checked by flake8
169170
"f-string-without-interpolation",
170171
"line-too-long",

Diff for: tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ disable = [
137137
# disabled because it conflicts with isort
138138
"wrong-import-order",
139139
"ungrouped-imports",
140-
# pylint's unsubscriptable check is buggy and is not needed because
141-
# it is a type-check, for which we already have mypy.
140+
# Checked by mypy (and pylint is very flaky checking these)
142141
"unsubscriptable-object",
143-
# Checked by mypy
144142
"no-member",
143+
"no-name-in-module",
144+
"possibly-used-before-assignment",
145145
# Checked by flake8
146146
"f-string-without-interpolation",
147147
"line-too-long",

Diff for: tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ disable = [
145145
# disabled because it conflicts with isort
146146
"wrong-import-order",
147147
"ungrouped-imports",
148-
# pylint's unsubscriptable check is buggy and is not needed because
149-
# it is a type-check, for which we already have mypy.
148+
# Checked by mypy (and pylint is very flaky checking these)
150149
"unsubscriptable-object",
151-
# Checked by mypy
152150
"no-member",
151+
"no-name-in-module",
152+
"possibly-used-before-assignment",
153153
# Checked by flake8
154154
"f-string-without-interpolation",
155155
"line-too-long",

Diff for: tests_golden/integration/test_cookiecutter_generation/app/frequenz-app-test/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ disable = [
136136
# disabled because it conflicts with isort
137137
"wrong-import-order",
138138
"ungrouped-imports",
139-
# pylint's unsubscriptable check is buggy and is not needed because
140-
# it is a type-check, for which we already have mypy.
139+
# Checked by mypy (and pylint is very flaky checking these)
141140
"unsubscriptable-object",
142-
# Checked by mypy
143141
"no-member",
142+
"no-name-in-module",
143+
"possibly-used-before-assignment",
144144
# Checked by flake8
145145
"f-string-without-interpolation",
146146
"line-too-long",

Diff for: tests_golden/integration/test_cookiecutter_generation/lib/frequenz-test-python/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ disable = [
133133
# disabled because it conflicts with isort
134134
"wrong-import-order",
135135
"ungrouped-imports",
136-
# pylint's unsubscriptable check is buggy and is not needed because
137-
# it is a type-check, for which we already have mypy.
136+
# Checked by mypy (and pylint is very flaky checking these)
138137
"unsubscriptable-object",
139-
# Checked by mypy
140138
"no-member",
139+
"no-name-in-module",
140+
"possibly-used-before-assignment",
141141
# Checked by flake8
142142
"f-string-without-interpolation",
143143
"line-too-long",

Diff for: tests_golden/integration/test_cookiecutter_generation/model/frequenz-model-test/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ disable = [
137137
# disabled because it conflicts with isort
138138
"wrong-import-order",
139139
"ungrouped-imports",
140-
# pylint's unsubscriptable check is buggy and is not needed because
141-
# it is a type-check, for which we already have mypy.
140+
# Checked by mypy (and pylint is very flaky checking these)
142141
"unsubscriptable-object",
143-
# Checked by mypy
144142
"no-member",
143+
"no-name-in-module",
144+
"possibly-used-before-assignment",
145145
# Checked by flake8
146146
"f-string-without-interpolation",
147147
"line-too-long",

0 commit comments

Comments
 (0)