From 868b80cc15936975ee1bbd27941cfac1217e1bec Mon Sep 17 00:00:00 2001
From: Ian Galpin <ian.galpin@geant.org>
Date: Wed, 16 Nov 2022 13:50:11 +0000
Subject: [PATCH] Added flake8-quotes checking and fixed flake8 double to
 single quote errors

---
 compendium_v2/app.py                   |  4 +--
 compendium_v2/routes/api.py            |  4 +--
 compendium_v2/routes/common.py         |  4 +--
 compendium_v2/routes/default.py        |  6 ++--
 compendium_v2/routes/service_matrix.py | 44 +++++++++++++-------------
 docs/source/conf.py                    |  4 +--
 requirements-dev.in                    |  2 ++
 requirements-dev.txt                   | 12 +++++++
 setup.py                               |  2 +-
 tox.ini                                |  1 +
 10 files changed, 49 insertions(+), 34 deletions(-)

diff --git a/compendium_v2/app.py b/compendium_v2/app.py
index 868719e1..acd1fab0 100644
--- a/compendium_v2/app.py
+++ b/compendium_v2/app.py
@@ -8,5 +8,5 @@ environment.setup_logging()
 
 app = compendium_v2.create_app()
 
-if __name__ == "__main__":
-    app.run(host="::", port="33333")
+if __name__ == '__main__':
+    app.run(host='::', port='33333')
diff --git a/compendium_v2/routes/api.py b/compendium_v2/routes/api.py
index 3adc75f7..3707e116 100644
--- a/compendium_v2/routes/api.py
+++ b/compendium_v2/routes/api.py
@@ -19,7 +19,7 @@ from flask import Blueprint, jsonify
 
 from compendium_v2.routes import common
 
-routes = Blueprint("compendium-v2-api", __name__)
+routes = Blueprint('compendium-v2-api', __name__)
 
 
 THING_LIST_SCHEMA = {
@@ -51,7 +51,7 @@ def after_request(resp):
     return common.after_request(resp)
 
 
-@routes.route("/things", methods=['GET', 'POST'])
+@routes.route('/things', methods=['GET', 'POST'])
 @common.require_accepts_json
 def things():
     """
diff --git a/compendium_v2/routes/common.py b/compendium_v2/routes/common.py
index 519b6f6b..e6de1a89 100644
--- a/compendium_v2/routes/common.py
+++ b/compendium_v2/routes/common.py
@@ -23,9 +23,9 @@ def require_accepts_json(f):
         # TODO: use best_match to disallow */* ...?
         if not request.accept_mimetypes.accept_json:
             return Response(
-                response="response will be json",
+                response='response will be json',
                 status=406,
-                mimetype="text/html")
+                mimetype='text/html')
         return f(*args, **kwargs)
     return decorated_function
 
diff --git a/compendium_v2/routes/default.py b/compendium_v2/routes/default.py
index 7211bb4e..8929292a 100644
--- a/compendium_v2/routes/default.py
+++ b/compendium_v2/routes/default.py
@@ -15,7 +15,7 @@ from flask import Blueprint, jsonify, render_template
 
 from compendium_v2.routes import common
 
-routes = Blueprint("compendium-v2-default", __name__)
+routes = Blueprint('compendium-v2-default', __name__)
 API_VERSION = '0.1'
 
 VERSION_SCHEMA = {
@@ -42,12 +42,12 @@ def after_request(resp):
     return common.after_request(resp)
 
 
-@routes.route("/", methods=['GET'])
+@routes.route('/', methods=['GET'])
 def index():
     return render_template('index.html')
 
 
-@routes.route("/version", methods=['GET', 'POST'])
+@routes.route('/version', methods=['GET', 'POST'])
 @common.require_accepts_json
 def version():
     """
diff --git a/compendium_v2/routes/service_matrix.py b/compendium_v2/routes/service_matrix.py
index 0f642c4a..798db6ec 100644
--- a/compendium_v2/routes/service_matrix.py
+++ b/compendium_v2/routes/service_matrix.py
@@ -22,31 +22,31 @@ from compendium_v2.routes import common
 
 SERVICE_MATRIX_SCHEMA = {
     '$schema': 'http://json-schema.org/draft-07/schema#',
-    "type": "object",
-    "properties": {
-        "key": {
-            "type": "string"
+    'type': 'object',
+    'properties': {
+        'key': {
+            'type': 'string'
         },
-        "nrens": {
-            "type": "array",
-            "items": {
-                "type": "object",
-                "properties": {
-                    "name": {
-                        "type": "string"
+        'nrens': {
+            'type': 'array',
+            'items': {
+                'type': 'object',
+                'properties': {
+                    'name': {
+                        'type': 'string'
                     },
-                    "nren_id": {
-                        "type": "integer"
+                    'nren_id': {
+                        'type': 'integer'
                     },
-                    "tags": {
-                        "type": "array",
-                        "items": {}
+                    'tags': {
+                        'type': 'array',
+                        'items': {}
                     }
                 },
-                "required": [
-                    "name",
-                    "nren_id",
-                    "tags"
+                'required': [
+                    'name',
+                    'nren_id',
+                    'tags'
                 ],
                 'additionalProperties': True
             }
@@ -60,7 +60,7 @@ DUMMY_DATA_FILENAME = os.path.abspath(os.path.join(
     'datasources',
     'dummy-service-matrix.json'
 ))
-routes = Blueprint("compendium-v2-service-matrix", __name__)
+routes = Blueprint('compendium-v2-service-matrix', __name__)
 logger = logging.getLogger(__name__)
 
 file_name = open(DUMMY_DATA_FILENAME)
@@ -68,7 +68,7 @@ file_name = open(DUMMY_DATA_FILENAME)
 service_matrix_response = json.loads(file_name.read())
 
 
-@routes.route("", methods=['GET'])
+@routes.route('', methods=['GET'])
 @common.require_accepts_json
 def get_service_matrix():
     """
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 2b3e6233..812d976f 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -99,5 +99,5 @@ html_static_path = ['_static']
 
 # Both the class’ and the __init__ method’s docstring
 # are concatenated and inserted.
-autoclass_content = "both"
-autodoc_typehints = "none"
+autoclass_content = 'both'
+autodoc_typehints = 'none'
diff --git a/requirements-dev.in b/requirements-dev.in
index f95df668..baff2d97 100644
--- a/requirements-dev.in
+++ b/requirements-dev.in
@@ -1,4 +1,6 @@
 -r requirements.txt
+flake8==5.0.4
+flake8-quotes==3.3.1
 isort==5.10.1
 pip-tools==6.10.0
 mypy==0.991
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 16acee83..27fc2c5d 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -47,6 +47,12 @@ filelock==3.8.0
     # via
     #   tox
     #   virtualenv
+flake8==5.0.4
+    # via
+    #   -r requirements-dev.in
+    #   flake8-quotes
+flake8-quotes==3.3.1
+    # via -r requirements-dev.in
 flask==2.2.2
     # via
     #   -r requirements.txt
@@ -95,6 +101,8 @@ markupsafe==2.1.1
     #   -r requirements.txt
     #   jinja2
     #   werkzeug
+mccabe==0.7.0
+    # via flake8
 mypy==0.991
     # via -r requirements-dev.in
 mypy-extensions==0.4.3
@@ -119,6 +127,10 @@ pluggy==1.0.0
     #   tox
 py==1.11.0
     # via tox
+pycodestyle==2.9.1
+    # via flake8
+pyflakes==2.5.0
+    # via flake8
 pygments==2.13.0
     # via
     #   -r requirements.txt
diff --git a/setup.py b/setup.py
index cd9291bc..071adf39 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
 
 setup(
     name='compendium-v2',
-    version="0.2",
+    version='0.2',
     author='GEANT',
     author_email='swd@geant.org',
     description='Flask and React project for displaying '
diff --git a/tox.ini b/tox.ini
index a870b92a..b89bcccf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,6 +9,7 @@ exclude = ./.tox,./webapp
 deps =
     coverage
     flake8
+    flake8-quotes
     isort
     -r requirements.txt
 
-- 
GitLab