Skip to content

Commit c2ad8d0

Browse files
[ruff] Activate flake8-pyi and fix existing issues
1 parent 53ca994 commit c2ad8d0

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

pylint/checkers/base_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __gt__(self, other: Any) -> bool:
6868
return not self_is_builtin
6969
return self.name > other.name
7070

71-
def __eq__(self, other: Any) -> bool:
71+
def __eq__(self, other: object) -> bool:
7272
"""Permit to assert Checkers are equal."""
7373
if not isinstance(other, BaseChecker):
7474
return False

pylint/checkers/similar.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
from itertools import chain
4545
from typing import (
4646
TYPE_CHECKING,
47-
Any,
4847
Dict,
4948
List,
5049
NamedTuple,
@@ -136,7 +135,7 @@ def __init__(self, fileid: str, num_line: int, *lines: Iterable[str]) -> None:
136135
self._hash: int = sum(hash(lin) for lin in lines)
137136
"""The hash of some consecutive lines."""
138137

139-
def __eq__(self, o: Any) -> bool:
138+
def __eq__(self, o: object) -> bool:
140139
if not isinstance(o, LinesChunk):
141140
return NotImplemented
142141
return self._hash == o._hash
@@ -195,7 +194,7 @@ def __repr__(self) -> str:
195194
f"<LineSetStartCouple <{self.fst_lineset_index};{self.snd_lineset_index}>>"
196195
)
197196

198-
def __eq__(self, other: Any) -> bool:
197+
def __eq__(self, other: object) -> bool:
199198
if not isinstance(other, LineSetStartCouple):
200199
return NotImplemented
201200
return (
@@ -717,7 +716,7 @@ def __lt__(self, other: LineSet) -> bool:
717716
def __hash__(self) -> int:
718717
return id(self)
719718

720-
def __eq__(self, other: Any) -> bool:
719+
def __eq__(self, other: object) -> bool:
721720
if not isinstance(other, LineSet):
722721
return False
723722
return self.__dict__ == other.__dict__

pylint/message/message_definition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
import sys
8-
from typing import TYPE_CHECKING, Any
8+
from typing import TYPE_CHECKING
99

1010
from astroid import nodes
1111

@@ -59,7 +59,7 @@ def check_msgid(msgid: str) -> None:
5959
if msgid[0] not in MSG_TYPES:
6060
raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid!r}")
6161

62-
def __eq__(self, other: Any) -> bool:
62+
def __eq__(self, other: object) -> bool:
6363
return (
6464
isinstance(other, MessageDefinition)
6565
and self.msgid == other.msgid

pylint/utils/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,12 @@ def normalize_text(
9797

9898

9999
# py3k has no more cmp builtin
100-
def cmp(a: int | float, b: int | float) -> int:
100+
def cmp(a: float, b: float) -> int:
101101
return (a > b) - (a < b)
102102

103103

104-
def diff_string(old: int | float, new: int | float) -> str:
105-
"""Given an old and new int value, return a string representing the
106-
difference.
107-
"""
104+
def diff_string(old: float, new: float) -> str:
105+
"""Given an old and new value, return a string representing the difference."""
108106
diff = abs(old - new)
109107
diff_str = f"{CMPS[cmp(old, new)]}{diff and f'{diff:.2f}' or ''}"
110108
return diff_str

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+
"PYI", # flake8-pyi
153154
"UP", # pyupgrade
154155
"RUF", # ruff
155156
"W", # pycodestyle

0 commit comments

Comments
 (0)