[ruff] Activate flake8-pie and fix existing issues
diff --git a/doc/test_messages_documentation.py b/doc/test_messages_documentation.py
index f024e03..96d98ed 100644
--- a/doc/test_messages_documentation.py
+++ b/doc/test_messages_documentation.py
@@ -140,7 +140,7 @@
line = match.group("line")
if line is None:
lineno = i + 1
- elif line.startswith("+") or line.startswith("-"):
+ elif line.startswith(("+", "-")):
lineno = i + 1 + int(line)
else:
lineno = int(line)
diff --git a/pylint/checkers/base/name_checker/checker.py b/pylint/checkers/base/name_checker/checker.py
index 82ff725..f6e1df5 100644
--- a/pylint/checkers/base/name_checker/checker.py
+++ b/pylint/checkers/base/name_checker/checker.py
@@ -688,7 +688,7 @@
confidence=interfaces.INFERENCE,
)
elif variance == TypeVarVariance.invariant and (
- name.endswith("_co") or name.endswith("_contra")
+ name.endswith(("_co", "_contra"))
):
suggest_name = re.sub("_contra$|_co$", "", name)
self.add_message(
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index 6f08bbc..6aa0f7c 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -647,10 +647,10 @@
line = line.strip()
if ignore_docstrings:
if not docstring:
- if line.startswith('"""') or line.startswith("'''"):
+ if line.startswith(('"""', "'''")):
docstring = line[:3]
line = line[3:]
- elif line.startswith('r"""') or line.startswith("r'''"):
+ elif line.startswith(('r"""', "r'''")):
docstring = line[1:4]
line = line[4:]
if docstring:
diff --git a/pylint/checkers/unicode.py b/pylint/checkers/unicode.py
index 30ae0af..deb8186 100644
--- a/pylint/checkers/unicode.py
+++ b/pylint/checkers/unicode.py
@@ -375,7 +375,7 @@
@staticmethod
def _is_invalid_codec(codec: str) -> bool:
- return codec.startswith("utf-16") or codec.startswith("utf-32")
+ return codec.startswith(("utf-16", "utf-32"))
@staticmethod
def _is_unicode(codec: str) -> bool:
diff --git a/pylint/config/config_initialization.py b/pylint/config/config_initialization.py
index 6fa7b6b..a6ce13b 100644
--- a/pylint/config/config_initialization.py
+++ b/pylint/config/config_initialization.py
@@ -169,7 +169,7 @@
all_action = ""
for i, arg in enumerate(config_args):
- if joined and (arg.startswith("--enable=") or arg.startswith("--disable=")):
+ if joined and (arg.startswith(("--enable=", "--disable="))):
value = arg.split("=")[1]
elif arg in {"--enable", "--disable"}:
value = config_args[i + 1]
diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py
index b578e31..48ee5a0 100644
--- a/pylint/testutils/lint_module_test.py
+++ b/pylint/testutils/lint_module_test.py
@@ -172,7 +172,7 @@
line = match.group("line")
if line is None:
lineno = i + 1
- elif line.startswith("+") or line.startswith("-"):
+ elif line.startswith(("+", "-")):
lineno = i + 1 + int(line)
else:
lineno = int(line)
diff --git a/pyproject.toml b/pyproject.toml
index 8de0d1f..32ef9dc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -150,6 +150,7 @@
"E", # pycodestyle
"F", # pyflakes
"I", # isort
+ "PIE", # flake8-pie
"PYI", # flake8-pyi
"UP", # pyupgrade
"RUF", # ruff