[ruff] Activate flake8-pyi and fix existing issues
diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py
index d06572a..6d577e0 100644
--- a/pylint/checkers/base_checker.py
+++ b/pylint/checkers/base_checker.py
@@ -68,7 +68,7 @@
return not self_is_builtin
return self.name > other.name
- def __eq__(self, other: Any) -> bool:
+ def __eq__(self, other: object) -> bool:
"""Permit to assert Checkers are equal."""
if not isinstance(other, BaseChecker):
return False
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index 4f6d41e..6f08bbc 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -44,7 +44,6 @@
from itertools import chain
from typing import (
TYPE_CHECKING,
- Any,
Dict,
List,
NamedTuple,
@@ -136,7 +135,7 @@
self._hash: int = sum(hash(lin) for lin in lines)
"""The hash of some consecutive lines."""
- def __eq__(self, o: Any) -> bool:
+ def __eq__(self, o: object) -> bool:
if not isinstance(o, LinesChunk):
return NotImplemented
return self._hash == o._hash
@@ -195,7 +194,7 @@
f"<LineSetStartCouple <{self.fst_lineset_index};{self.snd_lineset_index}>>"
)
- def __eq__(self, other: Any) -> bool:
+ def __eq__(self, other: object) -> bool:
if not isinstance(other, LineSetStartCouple):
return NotImplemented
return (
@@ -717,7 +716,7 @@
def __hash__(self) -> int:
return id(self)
- def __eq__(self, other: Any) -> bool:
+ def __eq__(self, other: object) -> bool:
if not isinstance(other, LineSet):
return False
return self.__dict__ == other.__dict__
diff --git a/pylint/message/message_definition.py b/pylint/message/message_definition.py
index eebcd5d..a318cc8 100644
--- a/pylint/message/message_definition.py
+++ b/pylint/message/message_definition.py
@@ -5,7 +5,7 @@
from __future__ import annotations
import sys
-from typing import TYPE_CHECKING, Any
+from typing import TYPE_CHECKING
from astroid import nodes
@@ -59,7 +59,7 @@
if msgid[0] not in MSG_TYPES:
raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid!r}")
- def __eq__(self, other: Any) -> bool:
+ def __eq__(self, other: object) -> bool:
return (
isinstance(other, MessageDefinition)
and self.msgid == other.msgid
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index 91f1cdd..2f30b95 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -97,14 +97,12 @@
# py3k has no more cmp builtin
-def cmp(a: int | float, b: int | float) -> int:
+def cmp(a: float, b: float) -> int:
return (a > b) - (a < b)
-def diff_string(old: int | float, new: int | float) -> str:
- """Given an old and new int value, return a string representing the
- difference.
- """
+def diff_string(old: float, new: float) -> str:
+ """Given an old and new value, return a string representing the difference."""
diff = abs(old - new)
diff_str = f"{CMPS[cmp(old, new)]}{diff and f'{diff:.2f}' or ''}"
return diff_str
diff --git a/pyproject.toml b/pyproject.toml
index 76341b8..8de0d1f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -150,6 +150,7 @@
"E", # pycodestyle
"F", # pyflakes
"I", # isort
+ "PYI", # flake8-pyi
"UP", # pyupgrade
"RUF", # ruff
"W", # pycodestyle