From 6c00816941b2d0f82227fbcec744aba8e0d29cf3 Mon Sep 17 00:00:00 2001 From: Rebecca Dang Date: Mon, 13 Jul 2020 19:50:00 -0700 Subject: [PATCH 01/10] Clarify instructions for Ch. 5 exercises --- 1_beginner/chapter5/practice/add_all_the_way.py | 9 ++++----- 1_beginner/chapter5/practice/up_2_fifty.py | 2 +- 1_beginner/chapter5/solutions/add_all_the_way.py | 9 ++++----- 1_beginner/chapter5/solutions/up_2_fifty.py | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/1_beginner/chapter5/practice/add_all_the_way.py b/1_beginner/chapter5/practice/add_all_the_way.py index fbd2f8a5..517f3ab8 100644 --- a/1_beginner/chapter5/practice/add_all_the_way.py +++ b/1_beginner/chapter5/practice/add_all_the_way.py @@ -1,8 +1,7 @@ # Add All the Way -# Write a program that asks for and -# reads an input from the user -# Then add all the numbers up from 0 -# to that number up. You can use a -# for or while loop. Print out the sum. +# Take a number from the user and +# add every number up from 1 to that number. +# Print the result. +# You can use a for or while loop. # write code here diff --git a/1_beginner/chapter5/practice/up_2_fifty.py b/1_beginner/chapter5/practice/up_2_fifty.py index 3d800176..d2b99f89 100644 --- a/1_beginner/chapter5/practice/up_2_fifty.py +++ b/1_beginner/chapter5/practice/up_2_fifty.py @@ -2,7 +2,7 @@ # Write a program that takes a number from the user # and adds 2 to it until it reaches 50 or more, # then prints out how many times 2 was added. -# If the number is already greater than 50, +# If the number is already 50 or greater, # then print out ('Already there!') # write code here diff --git a/1_beginner/chapter5/solutions/add_all_the_way.py b/1_beginner/chapter5/solutions/add_all_the_way.py index be0db267..84dc010c 100644 --- a/1_beginner/chapter5/solutions/add_all_the_way.py +++ b/1_beginner/chapter5/solutions/add_all_the_way.py @@ -1,9 +1,8 @@ # Add All the Way -# Write a program that asks for and -# reads an input from the user -# Then add all the numbers up from 0 -# to that number up. You can use a -# for or while loop. Print out the sum. +# Take a number from the user and +# add every number up from 1 to that number. +# Print the result. +# You can use a for or while loop. # for loop solution sum = 0 diff --git a/1_beginner/chapter5/solutions/up_2_fifty.py b/1_beginner/chapter5/solutions/up_2_fifty.py index 40547c92..1f68afe7 100644 --- a/1_beginner/chapter5/solutions/up_2_fifty.py +++ b/1_beginner/chapter5/solutions/up_2_fifty.py @@ -2,7 +2,7 @@ # Write a program that takes a number from the user # and adds 2 to it until it reaches 50 or more, # then prints out how many times 2 was added. -# If the number is already greater than 50, +# If the number is already 50 or greater, # then print out ('Already there!') # prompt user for a number From 52d9b439fa7ca01f725bca03b4c6dd21d0ec969d Mon Sep 17 00:00:00 2001 From: Rebecca Dang Date: Mon, 13 Jul 2020 19:58:55 -0700 Subject: [PATCH 02/10] Update max line length to 90 for flake8 --- .github/workflows/python-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 1e0834cc..ad44be5d 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -28,3 +28,4 @@ jobs: run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --format=flake8 env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} + flake8_args: "--max-line-length=90" From e45bda0d550d31b6ccb7ba68bb560d8bf36be8a9 Mon Sep 17 00:00:00 2001 From: Rebecca Dang Date: Mon, 13 Jul 2020 20:11:57 -0700 Subject: [PATCH 03/10] Update workflow with correct URL, only fail on new --- .github/workflows/python-lint.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index ad44be5d..dc67738b 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -1,5 +1,4 @@ - -# Uses (Lint Action): https://github.com/marketplace/actions/lint-action#supported-tools + # Uses (Lintly): https://github.com/grantmcconnaughey/Lintly # Submits code reviews based on flake8 output name: Python (Lintly) @@ -19,13 +18,12 @@ jobs: with: python-version: '3.x' - # Install flake8 and lintly + # Install flake8 and Lintly - name: Install Python dependencies run: pip install flake8 lintly # Run Lintly with flake8 - name: Lint with flake8 - run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --format=flake8 + uses: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --fail-on=new --use-checks env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} - flake8_args: "--max-line-length=90" From c258f9b30567fa7a5d51b02a53a071c7e53f8ee3 Mon Sep 17 00:00:00 2001 From: Rebecca Dang <35876322+phrdang@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:56:07 -0700 Subject: [PATCH 04/10] Fix Lintly options --- .github/workflows/python-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index dc67738b..073d5d8e 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -1,4 +1,4 @@ - # Uses (Lintly): https://github.com/grantmcconnaughey/Lintly +# Uses (Lintly): https://github.com/grantmcconnaughey/Lintly # Submits code reviews based on flake8 output name: Python (Lintly) @@ -24,6 +24,6 @@ jobs: # Run Lintly with flake8 - name: Lint with flake8 - uses: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --fail-on=new --use-checks + uses: flake8 | lintly --fail-on=new --use-checks env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} From e9bd22e1fd00e89fe7e3f207f6d19c2cd7a3c1f6 Mon Sep 17 00:00:00 2001 From: Rebecca Dang <35876322+phrdang@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:59:46 -0700 Subject: [PATCH 05/10] Put commit-sha option back in Lintly run --- .github/workflows/python-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 073d5d8e..8303ed85 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -24,6 +24,6 @@ jobs: # Run Lintly with flake8 - name: Lint with flake8 - uses: flake8 | lintly --fail-on=new --use-checks + uses: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --fail-on=new --use-checks env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} From 8782e3ee8b8cfa5ddd4a7c8de9797531cc00b602 Mon Sep 17 00:00:00 2001 From: Rebecca Dang <35876322+phrdang@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:03:48 -0700 Subject: [PATCH 06/10] Replace "uses" with "run" to fix lintly --- .github/workflows/python-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 8303ed85..7a53741b 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -24,6 +24,6 @@ jobs: # Run Lintly with flake8 - name: Lint with flake8 - uses: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --fail-on=new --use-checks + run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --fail-on=new --use-checks env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} From c7e503a80878c60afb6890d7d7d04ea4d003f384 Mon Sep 17 00:00:00 2001 From: Rebecca Dang Date: Tue, 14 Jul 2020 10:11:42 -0700 Subject: [PATCH 07/10] Make black have max line length 79 --- .github/workflows/python-format.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-format.yml b/.github/workflows/python-format.yml index 3f84f822..71331888 100644 --- a/.github/workflows/python-format.yml +++ b/.github/workflows/python-format.yml @@ -27,4 +27,5 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} black: true + black_args: --line-length 79 # same max line length as flake8 auto_fix: true # auto commit style fixes \ No newline at end of file From 903a3a0c0911a9b7ea2b26ba4542e83b3c062554 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 14 Jul 2020 17:12:19 +0000 Subject: [PATCH 08/10] Fix code style issues with Black --- 1_beginner/chapter2/solutions/favorite.py | 9 ++++++++- 1_beginner/chapter3/examples/logic_operators.py | 5 ++++- 1_beginner/chapter3/practice/change.py | 4 +++- 1_beginner/chapter3/solutions/change.py | 4 +++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/1_beginner/chapter2/solutions/favorite.py b/1_beginner/chapter2/solutions/favorite.py index ba82814c..0915dcb0 100644 --- a/1_beginner/chapter2/solutions/favorite.py +++ b/1_beginner/chapter2/solutions/favorite.py @@ -9,4 +9,11 @@ favorite_person = input("Who is your favorite person? ") # Display output -print(favorite_person + " bought you " + favorite_food + " and " + favorite_drink + ".") +print( + favorite_person + + " bought you " + + favorite_food + + " and " + + favorite_drink + + "." +) diff --git a/1_beginner/chapter3/examples/logic_operators.py b/1_beginner/chapter3/examples/logic_operators.py index 1ce49f1d..26792ff6 100644 --- a/1_beginner/chapter3/examples/logic_operators.py +++ b/1_beginner/chapter3/examples/logic_operators.py @@ -11,7 +11,10 @@ # or was_computer_bought = True was_bike_bought = False -print("Was a computer or bike bought? " + str(was_computer_bought or was_bike_bought)) +print( + "Was a computer or bike bought? " + + str(was_computer_bought or was_bike_bought) +) # not is_raining = False diff --git a/1_beginner/chapter3/practice/change.py b/1_beginner/chapter3/practice/change.py index 8dfbaa6c..443b95b6 100644 --- a/1_beginner/chapter3/practice/change.py +++ b/1_beginner/chapter3/practice/change.py @@ -19,6 +19,8 @@ CENTS_PER_DOLLAR = 100 -num_cents = int(float(input("How many dollars do you have: $")) * CENTS_PER_DOLLAR) +num_cents = int( + float(input("How many dollars do you have: $")) * CENTS_PER_DOLLAR +) # What do you do next? Write code here diff --git a/1_beginner/chapter3/solutions/change.py b/1_beginner/chapter3/solutions/change.py index d693b9b1..bad5b99b 100644 --- a/1_beginner/chapter3/solutions/change.py +++ b/1_beginner/chapter3/solutions/change.py @@ -23,7 +23,9 @@ CENTS_PER_NICKEL = 5 # prompt user for dollars and convert it to cents -num_cents = int(float(input("How many dollars do you have: $")) * CENTS_PER_DOLLAR) +num_cents = int( + float(input("How many dollars do you have: $")) * CENTS_PER_DOLLAR +) # calculate change and display it dollars = num_cents // CENTS_PER_DOLLAR From 37c0cb9aed6d5f134359b1f5b299a0cc01ce372c Mon Sep 17 00:00:00 2001 From: Rebecca Dang Date: Tue, 14 Jul 2020 10:12:40 -0700 Subject: [PATCH 09/10] Remove fail-on new so that flake8 checks all --- .github/workflows/python-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 7a53741b..d3651006 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -24,6 +24,6 @@ jobs: # Run Lintly with flake8 - name: Lint with flake8 - run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --fail-on=new --use-checks + run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --use-checks env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} From 7be5ac1115350b41d3a16ad539513d7d339a6e6f Mon Sep 17 00:00:00 2001 From: Rebecca Dang <35876322+phrdang@users.noreply.github.com> Date: Tue, 14 Jul 2020 13:05:10 -0700 Subject: [PATCH 10/10] Remove use-checks option so that it submits a review --- .github/workflows/python-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index d3651006..308b56a8 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -24,6 +24,6 @@ jobs: # Run Lintly with flake8 - name: Lint with flake8 - run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} --use-checks + run: flake8 | lintly --commit-sha=${{ github.event.pull_request.head.sha }} env: LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }}