Browse Source

Enable H904 check

H904  String interpolation should be delayed to be handled by the
logging code, rather than being done at the point of the logging call.
Use ',' instead of '%'.

See: https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages

Change-Id: I66ea69fe877fa57a54e06c22221cdd1f3414ef16
Related-Bug: #1596829
tags/0.4.0
Ngo Quoc Cuong 2 years ago
parent
commit
4e615d6da6
5 changed files with 9 additions and 10 deletions
  1. 2
    4
      glare/api/middleware/keycloak_auth.py
  2. 2
    2
      glare/common/store_api.py
  3. 1
    1
      glare/db/sqlalchemy/api.py
  4. 2
    2
      glare/scrubber.py
  5. 2
    1
      tox.ini

+ 2
- 4
glare/api/middleware/keycloak_auth.py View File

@@ -98,10 +98,8 @@ class KeycloakAuthMiddleware(base_middleware.Middleware):
98 98
                                   time=CONF.keycloak_oidc.token_cache_time)
99 99
             info = resp.json()
100 100
 
101
-        LOG.debug(
102
-            "HTTP response from OIDC provider: %s" %
103
-            pprint.pformat(info)
104
-        )
101
+        LOG.debug("HTTP response from OIDC provider: %s",
102
+                  pprint.pformat(info))
105 103
 
106 104
         return info
107 105
 

+ 2
- 2
glare/common/store_api.py View File

@@ -73,14 +73,14 @@ def save_blob_to_store(blob_id, blob, context, max_size,
73 73
         store_type = None
74 74
     data = utils.LimitingReader(utils.CooperativeReader(blob), max_size)
75 75
 
76
-    LOG.debug('Start uploading blob %s.' % blob_id)
76
+    LOG.debug('Start uploading blob %s.', blob_id)
77 77
     if store_type == 'database':
78 78
         location = database_api.add_to_backend(
79 79
             blob_id, data, context, verifier)
80 80
     else:
81 81
         (location, size, md5checksum, __) = backend.add_to_backend(
82 82
             CONF, blob_id, data, 0, store_type, context, verifier)
83
-    LOG.debug('Uploading of blob %s is finished.' % blob_id)
83
+    LOG.debug('Uploading of blob %s is finished.', blob_id)
84 84
 
85 85
     checksums = {"md5": data.md5.hexdigest(),
86 86
                  "sha1": data.sha1.hexdigest(),

+ 1
- 1
glare/db/sqlalchemy/api.py View File

@@ -167,7 +167,7 @@ def _create_or_update(context, artifact_id, values, session):
167 167
         artifact.update(values)
168 168
 
169 169
         LOG.debug('Sending request to the database. '
170
-                  'New values are %s' % values)
170
+                  'New values are %s', values)
171 171
         artifact.save(session=session)
172 172
         LOG.debug('Response from the database was received.')
173 173
 

+ 2
- 2
glare/scrubber.py View File

@@ -155,7 +155,7 @@ class Scrubber(object):
155 155
 
156 156
     @staticmethod
157 157
     def _scrub_artifact(af):
158
-        LOG.info("Begin scrubbing of artifact %s" % af.id)
158
+        LOG.info("Begin scrubbing of artifact %s", af.id)
159 159
         for blob in af.blobs:
160 160
             if not blob.external:
161 161
                 try:
@@ -168,4 +168,4 @@ class Scrubber(object):
168 168
         # delete artifact itself
169 169
         db_api.delete(context, af.id, db_api.get_session())
170 170
 
171
-        LOG.info("Artifact %s was scrubbed" % af.id)
171
+        LOG.info("Artifact %s was scrubbed", af.id)

+ 2
- 1
tox.ini View File

@@ -66,7 +66,8 @@ commands = bandit -c bandit.yaml -r glare -n5 -p gate
66 66
 # H405  multi line docstring summary not separated with an empty line
67 67
 ignore = H404,H405
68 68
 exclude = .venv,.git,.tox,dist,doc,etc,*glare/locale*,*lib/python*,*egg,build
69
-enable-extensions = H106,H203
69
+# H904 Delay string interpolations at logging calls.
70
+enable-extensions = H106,H203,H904
70 71
 
71 72
 [hacking]
72 73
 local-check-factory = glare.hacking.checks.factory

Loading…
Cancel
Save