From c8a26f5ad6a862d63b5ea5fca66d7e94621b9ec8 Mon Sep 17 00:00:00 2001 From: Hsin-Wen Chang Date: Wed, 4 Aug 2021 17:05:54 +0800 Subject: [PATCH 1/6] feat: Add flask init-db --- .github/workflows/python-app.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..d60e5dd --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,36 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: flask init-db + pytest From 71c788570e048f5ff69e9d8dec6555c531155bc9 Mon Sep 17 00:00:00 2001 From: Hsin-Wen Chang Date: Wed, 4 Aug 2021 17:12:33 +0800 Subject: [PATCH 2/6] style: Format --- .github/workflows/python-app.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index d60e5dd..fe3cbc2 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -32,5 +32,6 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest - run: flask init-db + run: + flask init-db pytest From 1793d2da60e4c03148072c5c6cae0d0e7577e635 Mon Sep 17 00:00:00 2001 From: Hsin-Wen Chang Date: Wed, 4 Aug 2021 17:15:56 +0800 Subject: [PATCH 3/6] fix: Typo --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index fe3cbc2..8d22b55 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -32,6 +32,6 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest - run: + run: | flask init-db pytest From 1f709da6eda774c02f09b13a8bbe1558ee50fb61 Mon Sep 17 00:00:00 2001 From: Hsin-Wen Chang Date: Wed, 4 Aug 2021 17:22:17 +0800 Subject: [PATCH 4/6] fix: sqlite3.ProgrammingError --- handlers/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/routes.py b/handlers/routes.py index d9d3b6e..06d5684 100644 --- a/handlers/routes.py +++ b/handlers/routes.py @@ -35,7 +35,7 @@ def remove_value(): db = get_db() db.execute( "DELETE FROM shoppinglist WHERE item = ?", - (item) # change this to (item,) <- the comma is what matters - don't ask me why... + (item,) # change this to (item,) <- the comma is what matters - don't ask me why... ) db.commit() return redirect("/", code=302) From 636c9536ac1e6dd4f149a6bd5829014e59fd9694 Mon Sep 17 00:00:00 2001 From: alice Date: Wed, 4 Aug 2021 17:26:12 +0800 Subject: [PATCH 5/6] Revert "fix: sqlite3.ProgrammingError" This reverts commit 1f709da6eda774c02f09b13a8bbe1558ee50fb61. --- handlers/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/routes.py b/handlers/routes.py index 06d5684..d9d3b6e 100644 --- a/handlers/routes.py +++ b/handlers/routes.py @@ -35,7 +35,7 @@ def remove_value(): db = get_db() db.execute( "DELETE FROM shoppinglist WHERE item = ?", - (item,) # change this to (item,) <- the comma is what matters - don't ask me why... + (item) # change this to (item,) <- the comma is what matters - don't ask me why... ) db.commit() return redirect("/", code=302) From 7dbe3a6d317cad391f302ac93e7ab1fc913caf7b Mon Sep 17 00:00:00 2001 From: alice Date: Wed, 4 Aug 2021 17:29:24 +0800 Subject: [PATCH 6/6] fix: sqlite3.ProgrammingError --- handlers/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/routes.py b/handlers/routes.py index d9d3b6e..06d5684 100644 --- a/handlers/routes.py +++ b/handlers/routes.py @@ -35,7 +35,7 @@ def remove_value(): db = get_db() db.execute( "DELETE FROM shoppinglist WHERE item = ?", - (item) # change this to (item,) <- the comma is what matters - don't ask me why... + (item,) # change this to (item,) <- the comma is what matters - don't ask me why... ) db.commit() return redirect("/", code=302)