Skip to content

Fixes for ruff rule RUF012 #8831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data_structures/queue/double_ended_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Deque:
the number of nodes
"""

__slots__ = ["_front", "_back", "_len"]
__slots__ = ("_front", "_back", "_len")

@dataclass
class _Node:
Expand All @@ -54,7 +54,7 @@ class _Iterator:
the current node of the iteration.
"""

__slots__ = ["_cur"]
__slots__ = "_cur"

def __init__(self, cur: Deque._Node | None) -> None:
self._cur = cur
Expand Down
6 changes: 3 additions & 3 deletions maths/least_common_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def benchmark():


class TestLeastCommonMultiple(unittest.TestCase):
test_inputs = [
test_inputs = (
(10, 20),
(13, 15),
(4, 31),
Expand All @@ -77,8 +77,8 @@ class TestLeastCommonMultiple(unittest.TestCase):
(12, 25),
(10, 25),
(6, 9),
]
expected_results = [20, 195, 124, 210, 1462, 60, 300, 50, 18]
)
expected_results = (20, 195, 124, 210, 1462, 60, 300, 50, 18)

def test_lcm_function(self):
for i, (first_num, second_num) in enumerate(self.test_inputs):
Expand Down
8 changes: 4 additions & 4 deletions project_euler/problem_054/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class PokerHand:
list.sort(), sorted()
"""

_HAND_NAME = [
_HAND_NAME = (
"High card",
"One pair",
"Two pairs",
Expand All @@ -81,9 +81,9 @@ class PokerHand:
"Four of a kind",
"Straight flush",
"Royal flush",
]
)

_CARD_NAME = [
_CARD_NAME = (
"", # placeholder as lists are zero indexed
"One",
"Two",
Expand All @@ -99,7 +99,7 @@ class PokerHand:
"Queen",
"King",
"Ace",
]
)

def __init__(self, hand: str) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ max-complexity = 17 # default: 10
"machine_learning/linear_discriminant_analysis.py" = ["ARG005"]
"machine_learning/sequential_minimum_optimization.py" = ["SIM115"]
"matrix/sherman_morrison.py" = ["SIM103", "SIM114"]
"other/lfu_cache.py" = ["RUF012"]
"physics/newtons_second_law_of_motion.py" = ["BLE001"]
"project_euler/problem_099/sol1.py" = ["SIM115"]
"sorts/external_sort.py" = ["SIM115"]
Expand Down