Repository: wagtail-nest/wagtail-hallo (language: python)

Issue:
Linting in GitHub Actions - migrate away from Tox
> * If we retain linting in GitHub Actions, I don’t think we should use tox for it. It’s very slow, so in my opinion not worth the hassle for flake8 and black.

_Originally posted by @lb- in https://github.com/wagtail/wagtail-hallo/issues/9#issuecomment-1056740702_


Discussion / hints:

Fix patch:
diff --git a/.circleci/report_nightly_build_failure.py b/.circleci/report_nightly_build_failure.py
index ef54fe5..eb1cba5 100644
--- a/.circleci/report_nightly_build_failure.py
+++ b/.circleci/report_nightly_build_failure.py
@@ -6,13 +6,18 @@
 import os
 import requests
 
-if 'SLACK_WEBHOOK_URL' in os.environ:
+if "SLACK_WEBHOOK_URL" in os.environ:
     print("Reporting to #nightly-build-failures slack channel")
-    response = requests.post(os.environ['SLACK_WEBHOOK_URL'], json={
-        "text": "A Nightly build failed. See " + os.environ['CIRCLE_BUILD_URL'],
-    })
+    response = requests.post(
+        os.environ["SLACK_WEBHOOK_URL"],
+        json={
+            "text": "A Nightly build failed. See " + os.environ["CIRCLE_BUILD_URL"],
+        },
+    )
 
     print("Slack responded with:", response)
 
 else:
-    print("Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set")
+    print(
+        "Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set"
+    )
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..5491ff9
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,6 @@
+[flake8]
+# E501: Line too long
+# W503: line break before binary operator (superseded by W504 line break after binary operator)
+ignore = E501,W503
+exclude = .git,build,__pycache__,node_modules
+max-complexity = 10
diff --git a/.github/workflows/test.yml b/.github/workflows/ci.yml
similarity index 84%
rename from .github/workflows/test.yml
rename to .github/workflows/ci.yml
index e43d945..9164492 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/ci.yml
@@ -10,6 +10,7 @@ on:
 
 jobs:
   check-client:
+    name: 🧑‍🚀 preflight (check client)
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
@@ -25,27 +26,21 @@ jobs:
         run: npm ci
       - run: npm run preflight
 
-  check-server:
+  check-server-black:
+    name: ⚫ Black (check server)
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
-      - name: Set up Python
-        uses: actions/setup-python@v2
-        with:
-          python-version: '3.9'
-      - name: Install Tox
-        run: |
-          python -m pip install tox
-      - name: Check flake8
-        run: |
-          tox
-        env:
-          TOXENV: flake8
-      - name: Check black
-        run: |
-          tox
-        env:
-          TOXENV: black
+      - name: Python black Lint
+        uses: psf/black@stable
+
+  check-server-flake8:
+    name: 🎱 flake8 (check server)
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Python flake8 Lint
+        uses: py-actions/flake8@v2.0.0
 
   test-sqlite:
     runs-on: ubuntu-latest
diff --git a/setup.py b/setup.py
index aa70433..2102df4 100644
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,7 @@
     version=__version__,
     description="Wagtail Hallo - The legacy richtext editor for Wagtail.",
     long_description=long_description,
-    long_description_content_type='text/markdown',
+    long_description_content_type="text/markdown",
     author="Wagtail core team",
     author_email="hello@wagtail.org",
     url="https://github.com/wagtail/wagtail-hallo",
diff --git a/tox.ini b/tox.ini
index 02b4b41..d084bab 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,12 +4,6 @@ usedevelop = True
 
 envlist = python{3.7,3.8,3.9}-django{3.2,4.0,main}-wagtail{2.15,2.16,main}-{sqlite,postgres}
 
-[flake8]
-# E501: Line too long
-# W503: line break before binary operator (superseded by W504 line break after binary operator)
-ignore = E501,W503
-exclude = node_modules
-
 [testenv]
 install_command = pip install -e ".[testing]" -U {opts} {packages}
 commands = coverage run testmanage.py test --deprecation all
@@ -34,13 +28,3 @@ deps =
 
 setenv =
     postgres: DATABASE_URL={env:DATABASE_URL:postgres:///wagtail_hallo}
-
-[testenv:flake8]
-basepython=python3.9
-deps=flake8>=2.2.0
-commands=flake8 wagtail_hallo
-
-[testenv:black]
-basepython=python3.9
-deps=black>=22.1.0
-commands=black wagtail_hallo --check


Test patch:
diff --git a/testmanage.py b/testmanage.py
index 84cb7f6..09fb1bc 100644
--- a/testmanage.py
+++ b/testmanage.py
@@ -61,8 +61,6 @@ def runtests():
         shutil.rmtree(STATIC_ROOT, ignore_errors=True)
         shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
 
-    
-
 
 if __name__ == "__main__":
     runtests()
diff --git a/wagtail_hallo/test/tests/utils.py b/wagtail_hallo/test/tests/utils.py
index d1a2d84..2c8ea60 100644
--- a/wagtail_hallo/test/tests/utils.py
+++ b/wagtail_hallo/test/tests/utils.py
@@ -9,7 +9,7 @@ def create_test_user():
         """
         user_model = get_user_model()
         # Create a user
-        user_data = dict()
+        user_data = {}
         user_data[user_model.USERNAME_FIELD] = "test@email.com"
         user_data["email"] = "test@email.com"
         user_data["password"] = "password"