@@ -92,6 +92,42 @@ def replace_file_contents_atomically( # noqa; DOC501
92
92
raise
93
93
94
94
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
+
95
131
def main () -> None :
96
132
"""Run the migration steps."""
97
133
# Dependabot patch
@@ -128,6 +164,9 @@ def main() -> None:
128
164
)
129
165
print ("=" * 72 )
130
166
167
+ # Add new pylint checks
168
+ add_pylint_checks ()
169
+
131
170
# Add a separation line like this one after each migration step.
132
171
print ("=" * 72 )
133
172
0 commit comments