Skip to content

Commit e394f32

Browse files
[ruff] Activate flake8-pie and fix existing issues
1 parent c2ad8d0 commit e394f32

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

doc/test_messages_documentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def get_expected_messages(stream: TextIO) -> MessageCounter:
140140
line = match.group("line")
141141
if line is None:
142142
lineno = i + 1
143-
elif line.startswith("+") or line.startswith("-"):
143+
elif line.startswith(("+", "-")):
144144
lineno = i + 1 + int(line)
145145
else:
146146
lineno = int(line)

pylint/checkers/base/name_checker/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def _check_typevar(self, name: str, node: nodes.AssignName) -> None:
688688
confidence=interfaces.INFERENCE,
689689
)
690690
elif variance == TypeVarVariance.invariant and (
691-
name.endswith("_co") or name.endswith("_contra")
691+
name.endswith(("_co", "_contra"))
692692
):
693693
suggest_name = re.sub("_contra$|_co$", "", name)
694694
self.add_message(

pylint/checkers/similar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,10 @@ def _get_functions(
647647
line = line.strip()
648648
if ignore_docstrings:
649649
if not docstring:
650-
if line.startswith('"""') or line.startswith("'''"):
650+
if line.startswith(('"""', "'''")):
651651
docstring = line[:3]
652652
line = line[3:]
653-
elif line.startswith('r"""') or line.startswith("r'''"):
653+
elif line.startswith(('r"""', "r'''")):
654654
docstring = line[1:4]
655655
line = line[4:]
656656
if docstring:

pylint/checkers/unicode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class UnicodeChecker(checkers.BaseRawFileChecker):
375375

376376
@staticmethod
377377
def _is_invalid_codec(codec: str) -> bool:
378-
return codec.startswith("utf-16") or codec.startswith("utf-32")
378+
return codec.startswith(("utf-16", "utf-32"))
379379

380380
@staticmethod
381381
def _is_unicode(codec: str) -> bool:

pylint/config/config_initialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _order_all_first(config_args: list[str], *, joined: bool) -> list[str]:
169169
all_action = ""
170170

171171
for i, arg in enumerate(config_args):
172-
if joined and (arg.startswith("--enable=") or arg.startswith("--disable=")):
172+
if joined and (arg.startswith(("--enable=", "--disable="))):
173173
value = arg.split("=")[1]
174174
elif arg in {"--enable", "--disable"}:
175175
value = config_args[i + 1]

pylint/testutils/lint_module_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def get_expected_messages(stream: TextIO) -> MessageCounter:
172172
line = match.group("line")
173173
if line is None:
174174
lineno = i + 1
175-
elif line.startswith("+") or line.startswith("-"):
175+
elif line.startswith(("+", "-")):
176176
lineno = i + 1 + int(line)
177177
else:
178178
lineno = int(line)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ select = [
150150
"E", # pycodestyle
151151
"F", # pyflakes
152152
"I", # isort
153+
"PIE", # flake8-pie
153154
"PYI", # flake8-pyi
154155
"UP", # pyupgrade
155156
"RUF", # ruff

0 commit comments

Comments
 (0)