From d958fa7e963c072149186209df16c7cd0d1e17f7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 30 Dec 2020 13:17:43 -0700 Subject: [PATCH] Add a "make flake" recipe and clean up some style bugs flake8 noticed We also ignore some rules about whether or not there's a space on either side of some operators, since I fundmanetally disagree with flake8 on some of these. --- .flake8 | 2 +- Makefile | 4 ++++ turbot/interaction.py | 3 ++- turbot/sheets.py | 9 ++++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index f929154..f31fa66 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,2 @@ [flake8] -ignore = E251, E305, E302, W503, E201, E202 +ignore = E251, E305, E302, W503, E201, E202, E225, E226, E203 diff --git a/Makefile b/Makefile index c0984d9..606418e 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,10 @@ ifndef VIRTUAL_ENV $(error "No virtualenv active. Try '. ./env/bin/activate'") endif +.PHONY: flake +flake: + flake8 --exclude=env,.deploy* + .PHONY: bootstrap bootstrap: @echo "=== Creating python virtual environment ===" diff --git a/turbot/interaction.py b/turbot/interaction.py index 5549aa8..343eca6 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -482,7 +482,8 @@ def solved(turb, body, args): set_channel_topic(turb, puzzle) # And rename the sheet to prefix with "SOLVED: " - turbot.sheets.renameSheet(turb, puzzle['sheet_url'], 'SOLVED: ' + puzzle['name']) + turbot.sheets.renameSheet(turb, puzzle['sheet_url'], + 'SOLVED: ' + puzzle['name']) # Finally, rename the Slack channel to add the suffix '-solved' channel_name = "{}-{}-solved".format( diff --git a/turbot/sheets.py b/turbot/sheets.py index 806ba19..bc7c7c6 100644 --- a/turbot/sheets.py +++ b/turbot/sheets.py @@ -61,7 +61,10 @@ def sheets_create_for_puzzle(turb, puzzle): insertDataOption='INSERT_ROWS', body={ 'range': 'A1:A2', - 'values': [['=HYPERLINK("'+url_link+'","'+url_text+'")'], ['=HYPERLINK("'+channel_url_link+'","'+channel_url_text+'")']] + 'values': [ + ['=HYPERLINK("'+url_link+'","'+url_text+'")'], + ['=HYPERLINK("'+channel_url_link+'","'+channel_url_text+'")'] + ] }).execute() # Copy some sheets from the Template spreadsheet @@ -100,8 +103,8 @@ def renameSheet(turb, url, newName): ).execute() def extractIdFromSheetUrl(url): - # Google sheet ids are between the /d/ and /edit in the url, like https://docs.google.com/spreadsheets/d/1dxHBzjenjhCAJQ8lM0skJO2mxlup8aWZm0-LaXeVPrg/edit#gid=0 + # Google sheet ids are between the /d/ and /edit in the url, like + # https://docs.google.com/spreadsheets/d/1dxHBzjen...-LaXeVPrg/edit#gid=0 startIndex = url.find('/d/') + 3 endIndex = url.find('/edit') return url[startIndex : endIndex] - \ No newline at end of file -- 2.43.0