Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Change `edit_uri` default branch to v0.x.x in mkdocs.yml.
* Added a new default option `asyncio_default_fixture_loop_scope = "function"` for `pytest-asyncio` as not providing a value is deprecated.
* The migration script is now written in Python, so it should be (hopefully) more compatible with different OSes.
* Disable more `pylint` checks that are also checked by `mypy` to avoid false positives.

## Bug Fixes

Expand Down
39 changes: 39 additions & 0 deletions cookiecutter/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,42 @@ def replace_file_contents_atomically( # noqa; DOC501
raise


def add_pylint_checks() -> None:
"""Add new pylint checks to the project."""
pyproject_toml = Path("pyproject.toml")
print(
f"{pyproject_toml}: Skip some flaky pylint checks that are checked better by mypy."
)
marker = ' "no-member",\n'
pyproject_toml_content = pyproject_toml.read_text(encoding="utf-8")
if pyproject_toml_content.find(marker) == -1:
manual_step(
f"""\
{pyproject_toml}: We couldn't find the marker {marker!r} in the file.
Please add the following lines to the file manually in the
`[tool.pylint.messages_control]` section, under the `disable` key (ideally below other
checks that are disabled because `mypy` already checks them) if they are missing:
"no-name-in-module",
"possibly-used-before-assignment",
"""
)
return

replacement = ""
if pyproject_toml_content.find("possibly-used-before-assignment") == -1:
replacement += ' "possibly-used-before-assignment",\n'
if pyproject_toml_content.find("no-name-in-module") == -1:
replacement += ' "no-name-in-module",\n'

if not replacement:
print(f"{pyproject_toml}: seems to be already up-to-date.")
return

replace_file_contents_atomically(
pyproject_toml, marker, marker + replacement, content=pyproject_toml_content
)


def main() -> None:
"""Run the migration steps."""
# Dependabot patch
Expand Down Expand Up @@ -128,6 +164,9 @@ def main() -> None:
)
print("=" * 72)

# Add new pylint checks
add_pylint_checks()

# Add a separation line like this one after each migration step.
print("=" * 72)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
# Checked by mypy
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,15 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
"missing-function-docstring",
"redefined-outer-name",
"unnecessary-lambda-assignment",
"unused-import",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
# Checked by mypy
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
# Checked by mypy
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
# Checked by mypy
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
# Checked by mypy
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ disable = [
# disabled because it conflicts with isort
"wrong-import-order",
"ungrouped-imports",
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
# Checked by mypy (and pylint is very flaky checking these)
"unsubscriptable-object",
# Checked by mypy
"no-member",
"no-name-in-module",
"possibly-used-before-assignment",
# Checked by flake8
"f-string-without-interpolation",
"line-too-long",
Expand Down
Loading