Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a3d775b

Browse files
committed
Add pre commit hooks
1 parent 2d1410c commit a3d775b

File tree

9 files changed

+55
-31
lines changed

9 files changed

+55
-31
lines changed

‎.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.12.7
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
8+
- repo: https://github.com/psf/black
9+
rev: 25.1.0
10+
hooks:
11+
- id: black
12+
language_version: python3.13

‎array_string/can_place_flowers/solution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:
88
for index in range(len(flowerbed)):
99
if flowerbed[index] == 0:
1010
left_is_empty = (index == 0) or (flowerbed[index - 1] == 0)
11-
right_is_empty = (index == len(flowerbed) - 1) or (flowerbed[index + 1] == 0)
11+
right_is_empty = (index == len(flowerbed) - 1) or (
12+
flowerbed[index + 1] == 0
13+
)
1214
if left_is_empty and right_is_empty:
1315
flowerbed[index] = 1
1416
counter += 1

‎array_string/greatest_common_divisor_of_strings/solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ def is_valid_gcd(index):
1212
for i in range(min(length1, length2), 0, -1):
1313
if is_valid_gcd(i):
1414
return str1[:i]
15-
return ""
15+
return ""

‎array_string/kids_with_the_greatest_number_of_candies/solution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
class Solution:
55
def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
66
max_candies = max(candies)
7-
return [current_candies + extraCandies >= max_candies for current_candies in candies]
7+
return [
8+
current_candies + extraCandies >= max_candies for current_candies in candies
9+
]

‎array_string/merge_strings_alternately/solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ def mergeAlternately(self, word1: str, word2: str) -> str:
88
if index < len(word2):
99
result.append(word2[index])
1010

11-
return ''.join(result)
11+
return "".join(result)

‎tests/test_can_place_flowers.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import pytest
22
from array_string.can_place_flowers.solution import Solution
33

4-
@pytest.mark.parametrize("flowerbed, n, expected", [
5-
([1, 0, 0, 0, 1], 1, True),
6-
([1, 0, 0, 0, 1], 2, False),
7-
([1,0,1,0,1,0,1], 1, False),
8-
([1, 0, 0, 0, 1, 0, 0], 2, True),
9-
([0], 1, True),
10-
([1,0,1,0,1,0,1], 0, True)
11-
])
4+
5+
@pytest.mark.parametrize(
6+
"flowerbed, n, expected",
7+
[
8+
([1, 0, 0, 0, 1], 1, True),
9+
([1, 0, 0, 0, 1], 2, False),
10+
([1, 0, 1, 0, 1, 0, 1], 1, False),
11+
([1, 0, 0, 0, 1, 0, 0], 2, True),
12+
([0], 1, True),
13+
([1, 0, 1, 0, 1, 0, 1], 0, True),
14+
],
15+
)
1216
def test_merge_alternately(flowerbed, n, expected):
1317
solution = Solution()
14-
assert solution.canPlaceFlowers(flowerbed, n) == expected
18+
assert solution.canPlaceFlowers(flowerbed, n) == expected
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pytest
22
from array_string.greatest_common_divisor_of_strings.solution import Solution
33

4-
@pytest.mark.parametrize("str1, str2, expected", [
5-
("ABCABC", "ABC", "ABC"),
6-
("ABABAB", "ABAB", "AB"),
7-
("LEET", "CODE", "")
8-
])
4+
5+
@pytest.mark.parametrize(
6+
"str1, str2, expected",
7+
[("ABCABC", "ABC", "ABC"), ("ABABAB", "ABAB", "AB"), ("LEET", "CODE", "")],
8+
)
99
def test_merge_alternately(str1, str2, expected):
1010
solution = Solution()
11-
assert solution.gcdOfStrings(str1, str2) == expected
11+
assert solution.gcdOfStrings(str1, str2) == expected

‎tests/test_kids_with_candies.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import pytest
22
from array_string.kids_with_the_greatest_number_of_candies.solution import Solution
33

4-
@pytest.mark.parametrize("candies, extraCandies, expected", [
5-
([2, 3, 5, 1, 3], 3, [True, True, True, False, True] ),
6-
([4, 2, 1, 1, 2], 1, [True, False, False, False, False]),
7-
([12, 1, 12], 10, [True, False, True])
8-
])
4+
5+
@pytest.mark.parametrize(
6+
"candies, extraCandies, expected",
7+
[
8+
([2, 3, 5, 1, 3], 3, [True, True, True, False, True]),
9+
([4, 2, 1, 1, 2], 1, [True, False, False, False, False]),
10+
([12, 1, 12], 10, [True, False, True]),
11+
],
12+
)
913
def test_merge_alternately(candies, extraCandies, expected):
1014
solution = Solution()
11-
assert solution.kidsWithCandies(candies, extraCandies) == expected
15+
assert solution.kidsWithCandies(candies, extraCandies) == expected

‎tests/test_merge_strings_alternately.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pytest
22
from array_string.merge_strings_alternately.solution import Solution
33

4-
@pytest.mark.parametrize("word1, word2, expected", [
5-
("abc", "pqr", "apbqcr"),
6-
("ab", "pqrs", "apbqrs"),
7-
("abcd", "pq", "apbqcd")
8-
])
4+
5+
@pytest.mark.parametrize(
6+
"word1, word2, expected",
7+
[("abc", "pqr", "apbqcr"), ("ab", "pqrs", "apbqrs"), ("abcd", "pq", "apbqcd")],
8+
)
99
def test_merge_alternately(word1, word2, expected):
1010
solution = Solution()
11-
assert solution.mergeAlternately(word1, word2) == expected
11+
assert solution.mergeAlternately(word1, word2) == expected

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /