Skip to content

Commit ef36c63

Browse files
committed
flake8
1 parent 409833f commit ef36c63

File tree

16 files changed

+108
-66
lines changed

16 files changed

+108
-66
lines changed

.flake8

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# https://flake8.pycqa.org/en/3.1.1/user/configuration.html#configuration
44
# Errors to exclude:
55
# W191 indentation contains tabs
6-
ignore = W191, W503
6+
ignore = W191, W503, E203
77
exclude =
8+
solutions/,
9+
*_test.py,
810
.git,
911
__pycache__,
1012
.circleci,
@@ -21,5 +23,4 @@ exclude =
2123
/.venv/,
2224
/.venv,
2325
migrations,
24-
max-complexity = 10
25-
max-line-length = 145
26+
max-complexity = 10

.github/workflows/flake8.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ jobs:
6060
# Changing the Ignore List
6161
# W191 indentation contains tabs
6262
run: |
63-
python -m flake8 . --count --select=E9,F63,F7,F82 --doctests --show-source --statistics
63+
python -m flake8 . --count --doctests --show-source --statistics

bob/bob.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
"""
2-
Your task is to determine what Bob will reply to someone when they say something
3-
to him or ask him a question.
2+
Your task is to determine what Bob will reply to someone when
3+
they say something to him or ask him a question.
44
55
Bob only ever answers one of five things:
66
7-
- "Sure." This is his response if you ask him a question, such as "How are you?"
7+
- "Sure." This is his response if you ask him a question,
8+
such as "How are you?"
89
The convention used for questions is that it ends with a question mark.
910
- "Whoa, chill out!" This is his answer if you YELL AT HIM.
1011
The convention used for yelling is ALL CAPITAL LETTERS.
11-
- "Calm down, I know what I'm doing!" This is what he says if you yell a question at him.
12+
- "Calm down, I know what I'm doing!" This is what he says if you
13+
yell a question at him.
1214
- "Fine. Be that way!" This is how he responds to silence.
13-
The convention used for silence is nothing, or various combinations of whitespace characters.
15+
The convention used for silence is nothing, or various combinations
16+
of whitespace characters.
1417
- "Whatever." This is what he answers to anything else.
1518
"""
1619

1720

1821
def response(hey_bob: str) -> str:
1922
"""
20-
Determine what Bob will reply to someone when they say something to him or ask him a question.
23+
Determine what Bob will reply to someone when they say
24+
something to him or ask him a question.
2125
2226
:param hey_bob: str
2327
:return: str

card-games/lists.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
22
Functions for tracking poker hands and assorted card tasks.
33
4-
Python list documentation: https://docs.python.org/3/tutorial/datastructures.html
4+
Python list documentation:
5+
https://docs.python.org/3/tutorial/datastructures.html
56
"""
67

78

@@ -49,18 +50,22 @@ def card_average(hand: list[list]) -> float:
4950

5051
def approx_average_is_average(hand: list[int]) -> bool:
5152
"""
52-
Return if the (average of first and last card values) OR ('middle' card) == calculated average.
53+
Return if the (average of first and last card values) OR
54+
('middle' card) == calculated average.
5355
5456
:param hand: list - cards in hand.
55-
:return: bool - does one of the approximate averages equal the `true average`?
57+
:return: bool - does one of the approximate averages
58+
equal the `true average`?
5659
"""
5760
avg: float = card_average(hand)
5861
return avg in ((hand[0] + hand[-1]) / 2, hand[len(hand) // 2])
5962

6063

6164
def average_even_is_average_odd(hand: list[int]) -> bool:
6265
"""
63-
Return if the (average of even indexed card values) == (average of odd indexed card values).
66+
Return if the
67+
(average of even indexed card values) ==
68+
(average of odd indexed card values).
6469
6570
:param hand: list - cards in hand.
6671
:return: bool - are even and odd averages equal?

chaitanas-colossal-coaster/list_methods.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def add_me_to_the_queue(
88
person_name: str,
99
) -> list[str]:
1010
"""
11-
Add a person to the 'express' or 'normal' queue depending on the ticket number.
11+
Add a person to the 'express' or 'normal' queue depending
12+
on the ticket number.
1213
1314
:param express_queue: list[str] - names in the Fast-track queue.
1415
:param normal_queue: list[str] - names in the normal queue.
@@ -35,7 +36,9 @@ def find_my_friend(queue: list[str], friend_name: str) -> int:
3536
return queue.index(friend_name)
3637

3738

38-
def add_me_with_my_friends(queue: list[str], index: int, person_name: str) -> list[str]:
39+
def add_me_with_my_friends(
40+
queue: list[str], index: int, person_name: str
41+
) -> list[str]:
3942
"""
4043
Insert the late arrival's name at a specific index of the queue.
4144

currency-exchange/exchange.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def get_change(budget: float, exchanging_value: float) -> float:
2828
Return the amount of money that "is left" from the budget.
2929
3030
:param budget: float - amount of money you own.
31-
:param exchanging_value: float - amount of your money you want to exchange now.
31+
:param exchanging_value: float - amount of your money you want to
32+
exchange now.
3233
:return: float - amount left of your starting currency after exchanging.
3334
"""
3435
return budget - exchanging_value # pylint: disable=R0801
@@ -51,7 +52,8 @@ def get_value_of_bills(denomination: float, number_of_bills: float) -> float:
5152

5253
def get_number_of_bills(amount: float, denomination: int) -> int:
5354
"""
54-
Return the _number of currency bills_ that you can receive within the given _amount_.
55+
Return the _number of currency bills_ that you can receive within
56+
the given _amount_.
5557
5658
:param amount: float - the total starting value.
5759
:param denomination: int - the value of a single bill.
@@ -62,12 +64,13 @@ def get_number_of_bills(amount: float, denomination: int) -> int:
6264

6365
def get_leftover_of_bills(amount: float, denomination: int) -> float:
6466
"""
65-
Return the _leftover amount_ that cannot be returned from your starting _amount_
66-
given the denomination of bills.
67+
Return the _leftover amount_ that cannot be returned from your
68+
starting _amount_ given the denomination of bills.
6769
6870
:param amount: float - the total starting value.
6971
:param denomination: int - the value of a single bill.
70-
:return: float - the amount that is "leftover", given the current denomination.
72+
:return: float - the amount that is "leftover", given the current
73+
denomination.
7174
"""
7275
return amount % denomination
7376

@@ -80,7 +83,8 @@ def exchangeable_value(
8083
Return the maximum value of the new currency after calculating
8184
the *exchange rate* plus the *spread*.
8285
83-
:param budget: float - the amount of your money you are planning to exchange.
86+
:param budget: float - the amount of your money you are planning
87+
to exchange.
8488
:param exchange_rate: float - the unit value of the foreign currency.
8589
:param spread: int - percentage that is taken as an exchange fee.
8690
:param denomination: int - the value of a single bill.

ghost-gobble-arcade-game/arcade_game.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def eat_ghost(power_pellet_active: bool, touching_ghost: bool) -> bool:
55
"""
66
Verify that Pac-Man can eat a ghost if he is empowered by a power pellet.
77
8-
:param power_pellet_active: bool - does the player have an active power pellet?
8+
:param power_pellet_active: bool - does the player have an active
9+
power pellet?
910
:param touching_ghost: bool - is the player touching a ghost?
1011
:return: bool - can a ghost be eaten?
1112
"""
@@ -25,9 +26,11 @@ def score(touching_power_pellet: bool, touching_dot: bool) -> bool:
2526

2627
def lose(power_pellet_active: bool, touching_ghost: bool) -> bool:
2728
"""
28-
Trigger the game loop to end (GAME OVER) when Pac-Man touches a ghost without his power pellet.
29+
Trigger the game loop to end (GAME OVER) when Pac-Man touches
30+
a ghost without his power pellet.
2931
30-
:param power_pellet_active: bool - does the player have an active power pellet?
32+
:param power_pellet_active: bool - does the player have an
33+
active power pellet?
3134
:param touching_ghost: bool - is the player touching a ghost?
3235
:return: bool - has the player lost the game?
3336
"""
@@ -41,7 +44,8 @@ def win(
4144
Trigger the victory event when all dots have been eaten.
4245
4346
:param has_eaten_all_dots: bool - has the player "eaten" all the dots?
44-
:param power_pellet_active: bool - does the player have an active power pellet?
47+
:param power_pellet_active: bool - does the player have an active
48+
power pellet?
4549
:param touching_ghost: bool - is the player touching a ghost?
4650
:return: bool - has the player won the game?
4751
"""

guidos-gorgeous-lasagna/lasagna.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def bake_time_remaining(elapsed_bake_time: int) -> int:
2222
based on the `EXPECTED_BAKE_TIME`.
2323
2424
:param elapsed_bake_time: int - baking time already elapsed.
25-
:return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.
25+
:return: int - remaining bake time (in minutes) derived from
26+
'EXPECTED_BAKE_TIME'.
2627
"""
2728
return EXPECTED_BAKE_TIME - elapsed_bake_time
2829

@@ -31,8 +32,8 @@ def preparation_time_in_minutes(number_of_layers: int) -> int:
3132
"""
3233
Calculate preparation time in minutes
3334
34-
Takes the `number_of_layers` you want to add to the lasagna as an argument and
35-
returns how many minutes you would spend making them.
35+
Takes the `number_of_layers` you want to add to the lasagna as an
36+
argument and returns how many minutes you would spend making them.
3637
3738
Assume each layer takes 2 minutes to prepare.
3839
@@ -44,12 +45,15 @@ def preparation_time_in_minutes(number_of_layers: int) -> int:
4445
return int(PREPARATION_TIME * number_of_layers)
4546

4647

47-
def elapsed_time_in_minutes(number_of_layers: int, elapsed_bake_time: int) -> int:
48+
def elapsed_time_in_minutes(
49+
number_of_layers: int, elapsed_bake_time: int
50+
) -> int:
4851
"""
4952
Calculate elapsed time in minutes.
5053
51-
Return the total minutes you have been in the kitchen cooking — your preparation time layering +
52-
the time the lasagna has spent baking in the oven.
54+
Return the total minutes you have been in the kitchen cooking — your
55+
preparation time layering + the time the lasagna has spent baking
56+
in the oven.
5357
5458
:param number_of_layers: The number of layers added to the lasagna.
5559
:type number_of_layers: int

little-sisters-vocab/strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def add_prefix_un(word: str) -> str:
1313

1414
def make_word_groups(vocab_words: list[str]) -> str:
1515
"""
16-
Transform a list containing a prefix and words into a string with the prefix
17-
followed by the words with prefix prepended.
16+
Transform a list containing a prefix and words into a string with
17+
the prefix followed by the words with prefix prepended.
1818
1919
:param vocab_words: list - of vocabulary words with prefix in first index.
2020
:return: str - of prefix followed by vocabulary words with

making-the-grade/loops.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def count_failed_students(student_scores: list) -> int:
1818
:param student_scores: list - containing int student scores.
1919
:return: int - count of student scores at or below 40.
2020
"""
21-
return len([score for score in student_scores if score <= 40.0]) # pylint: disable=R0801
21+
# pylint: disable=R0801
22+
return len([score for score in student_scores if score <= 40.0])
2223

2324

2425
def above_threshold(student_scores: list, threshold: int) -> list:
@@ -30,19 +31,21 @@ def above_threshold(student_scores: list, threshold: int) -> list:
3031
3132
:param student_scores: list - of integer scores.
3233
:param threshold: int - threshold to cross to be the "best" score.
33-
:return: list - of integer scores that are at or above the "best" threshold.
34+
:return: list - of integer scores that are at or above the "best"
35+
threshold.
3436
"""
35-
return [score for score in student_scores if score >= threshold] # pylint: disable=R0801
37+
# pylint: disable=R0801
38+
return [score for score in student_scores if score >= threshold]
3639

3740

3841
def letter_grades(highest: int) -> list:
3942
"""
4043
Create a list of grade thresholds based on the provided highest grade.
4144
4245
:param highest: int - value of highest exam score.
43-
:return: list - of lower threshold scores for each D-A letter grade interval.
44-
For example, where the highest score is 100, and failing is <= 40,
45-
The result would be [41, 56, 71, 86]:
46+
:return: list - of lower threshold scores for each D-A letter grade
47+
interval. For example, where the highest score is 100, and
48+
failing is <= 40, The result would be [41, 56, 71, 86]:
4649
4750
41 <= "D" <= 55
4851
56 <= "C" <= 70
@@ -56,10 +59,12 @@ def letter_grades(highest: int) -> list:
5659
# pylint: disable=R0801
5760
def student_ranking(student_scores: list, student_names: list) -> list[str]:
5861
"""
59-
Organize the student's rank, name, and grade information in descending order.
62+
Organize the student's rank, name, and grade information in descending
63+
order.
6064
6165
:param student_scores: list - of scores in descending order.
62-
:param student_names: list - of string names by exam score in descending order.
66+
:param student_names: list - of string names by exam score in descending
67+
order.
6368
:return: list - of strings in format ["<rank>. <student name>: <score>"].
6469
"""
6570
return [

0 commit comments

Comments
 (0)