Skip to content

Commit c5a9f4c

Browse files
committed
LINTING FIXES
1 parent 7fb88fd commit c5a9f4c

22 files changed

Lines changed: 388 additions & 201 deletions

File tree

.github/workflows/pylint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
run: |
1919
python -m pip install --upgrade pip
2020
pip install pylint
21+
pip install -r requirements.txt
2122
- name: Analysing the code with pylint
2223
run: |
23-
pylint $(git ls-files '*.py')
24+
python -m pylint --verbose $(Get-ChildItem -Recurse -Filter *.py | Where-Object { $_.FullName -notmatch '\\\.venv\\' -and $_.FullName -notmatch '\\venv\\' } | ForEach-Object { $_.FullName }) --rcfile=.pylintrc

.pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MASTER]
2+
ignore=.venv

armstrong-numbers/armstrong_numbers_test.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Armstrong Numbers Test Suite."""
2+
13
# These tests are auto-generated with test data from:
24
# https://github.com/exercism/problem-specifications/tree/main/exercises/armstrong-numbers/canonical-data.json
35
# File last updated on 2023-07-20
@@ -10,29 +12,88 @@
1012

1113

1214
class ArmstrongNumbersTest(unittest.TestCase):
15+
"""Armstrong Numbers Test."""
16+
1317
def test_zero_is_an_armstrong_number(self):
18+
"""
19+
Test that zero is correctly identified as an Armstrong number.
20+
21+
This test verifies that the function correctly determines that 0
22+
is an Armstrong number, as 0^1 == 0.
23+
24+
:returns: None
25+
:rtype: NoneType
26+
"""
1427
self.assertIs(is_armstrong_number(0), True)
1528

1629
def test_single_digit_numbers_are_armstrong_numbers(self):
30+
"""
31+
Test that all single digit numbers are Armstrong numbers.
32+
33+
:returns: None. Asserts that a single digit number (e.g., 5) is an Armstrong number.
34+
:rtype: NoneType
35+
"""
1736
self.assertIs(is_armstrong_number(5), True)
1837

1938
def test_there_are_no_two_digit_armstrong_numbers(self):
39+
"""
40+
Test that no two-digit numbers are Armstrong numbers.
41+
42+
:returns: None. Asserts that a two-digit number (e.g., 10) is not an Armstrong number.
43+
:rtype: NoneType
44+
"""
2045
self.assertIs(is_armstrong_number(10), False)
2146

2247
def test_three_digit_number_that_is_an_armstrong_number(self):
48+
"""
49+
Test that 153 is correctly identified as an Armstrong number.
50+
51+
:returns: None. Asserts that 153 is an Armstrong number.
52+
:rtype: NoneType
53+
"""
2354
self.assertIs(is_armstrong_number(153), True)
2455

2556
def test_three_digit_number_that_is_not_an_armstrong_number(self):
57+
"""
58+
Test that 100 is not identified as an Armstrong number.
59+
60+
:returns: None. Asserts that 100 is not an Armstrong number.
61+
:rtype: NoneType
62+
"""
2663
self.assertIs(is_armstrong_number(100), False)
2764

2865
def test_four_digit_number_that_is_an_armstrong_number(self):
66+
"""
67+
Test that 9474 is correctly identified as an Armstrong number.
68+
69+
:returns: None. Asserts that 9474 is an Armstrong number.
70+
:rtype: NoneType
71+
"""
2972
self.assertIs(is_armstrong_number(9474), True)
3073

3174
def test_four_digit_number_that_is_not_an_armstrong_number(self):
75+
"""
76+
Test that 9475 is not identified as an Armstrong number.
77+
78+
:returns: None. Asserts that 9475 is not an Armstrong number.
79+
:rtype: NoneType
80+
"""
3281
self.assertIs(is_armstrong_number(9475), False)
3382

3483
def test_seven_digit_number_that_is_an_armstrong_number(self):
84+
"""
85+
Test that 9926315 is correctly identified as an Armstrong number.
86+
87+
:returns: None. Asserts that 9926315 is an Armstrong number.
88+
:rtype: NoneType
89+
"""
3590
self.assertIs(is_armstrong_number(9926315), True)
3691

3792
def test_seven_digit_number_that_is_not_an_armstrong_number(self):
93+
"""
94+
Test that 9926314 is not identified as an Armstrong number.
95+
96+
:returns: None. Asserts that 9926314 is not an Armstrong number.
97+
:rtype: NoneType
98+
"""
3899
self.assertIs(is_armstrong_number(9926314), False)

black-jack/black_jack.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def value_of_card(card) -> int:
1919
"""
2020
if card in 'JKQ':
2121
return 10
22-
elif card == 'A':
22+
23+
if card == 'A':
2324
return 1
2425

2526
return int(card)
@@ -29,16 +30,19 @@ def higher_card(card_one, card_two) -> str | tuple[str, str]:
2930
"""
3031
Determine which card has a higher value in the hand.
3132
32-
:param card_one, card_two: str - cards dealt in hand. See below for values.
33-
:return: str or tuple - resulting Tuple contains both cards if they are of equal value.
33+
:param card_one: str - cards dealt in hand. See below for values.
34+
:param card_two: str - cards dealt in hand. See below for values.
35+
:return: str or tuple - resulting Tuple contains both cards if
36+
they are of equal value.
3437
3538
1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
3639
2. 'A' (ace card) = 1
3740
3. '2' - '10' = numerical value.
3841
"""
3942
if value_of_card(card_one) == value_of_card(card_two):
4043
return card_one, card_two
41-
elif value_of_card(card_one) > value_of_card(card_two):
44+
45+
if value_of_card(card_one) > value_of_card(card_two):
4246
return card_one
4347

4448
return card_two
@@ -56,11 +60,14 @@ def value_of_ace(card_one, card_two) -> int:
5660
3. '2' - '10' = numerical value.
5761
"""
5862
total: int = value_of_card(card_one) + value_of_card(card_two)
59-
# Hint: if we already have an ace in hand, then the value for the upcoming ace would be 1.
63+
# Hint: if we already have an ace in hand, then the value for
64+
# the upcoming ace would be 1.
6065
if card_one == 'A' or card_two == 'A':
6166
return 1
62-
# The value of the hand with the ace needs to be as high as possible without going over 21.
63-
elif 21 - total >= 11:
67+
# The value of the hand with the ace needs to be as high as
68+
# possible without going over 21.
69+
70+
if 21 - total >= 11:
6471
return 11
6572

6673
return 1
@@ -70,7 +77,10 @@ def is_blackjack(card_one, card_two) -> bool:
7077
"""
7178
Determine if the hand is a 'natural' or 'blackjack'.
7279
73-
:param card_one, card_two: str - card dealt. See below for values.
80+
:param card_one: card dealt. See below for values.
81+
:type card_one: str
82+
:param card_two: card dealt. See below for values.
83+
:type card_two: str
7484
:return: bool - is the hand is a blackjack (two cards worth 21).
7585
7686
1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
@@ -81,7 +91,8 @@ def is_blackjack(card_one, card_two) -> bool:
8191
# as their first two cards, then the player has a score of 21.
8292
if card_one == 'A' and card_two in ('J', 'Q', 'K', '10'):
8393
return True
84-
elif card_two == 'A' and card_one in ('J', 'Q', 'K', '10'):
94+
95+
if card_two == 'A' and card_one in ('J', 'Q', 'K', '10'):
8596
return True
8697

8798
return False
@@ -91,8 +102,10 @@ def can_split_pairs(card_one, card_two) -> bool:
91102
"""
92103
Determine if a player can split their hand into two hands.
93104
94-
:param card_one, card_two: str - cards dealt.
95-
:return: bool - can the hand be split into two pairs? (i.e. cards are of the same value).
105+
:param card_one: str - cards dealt.
106+
:param card_two: str - cards dealt.
107+
:return: bool - can the hand be split into two pairs?
108+
(i.e. cards are of the same value).
96109
"""
97110
if value_of_card(card_one) == value_of_card(card_two):
98111
return True
@@ -104,7 +117,9 @@ def can_double_down(card_one, card_two) -> bool:
104117
"""
105118
Determine if a blackjack player can place a double down bet.
106119
107-
:param card_one, card_two: str - first and second cards in hand.
108-
:return: bool - can the hand can be doubled down? (i.e. totals 9, 10 or 11 points).
120+
:param card_one: str - first and second cards in hand.
121+
:param card_two: str - first and second cards in hand.
122+
:return: bool - can the hand can be doubled down?
123+
(i.e. totals 9, 10 or 11 points).
109124
"""
110125
return 9 <= value_of_card(card_one) + value_of_card(card_two) <= 11

0 commit comments

Comments
 (0)