summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonathan de Jong <jonathan@automatia.nl>2021-03-24 14:34:30 +0100
committerGitHub <noreply@github.com>2021-03-24 09:34:30 -0400
commit4c3827f2c18180533b804ebd4d8f5cb90774244b (patch)
tree5a655fea7a1aeb307e09787f73a29db8918a0a64
parentSpaces summary: call out to other servers (#9653) (diff)
downloadsynapse-4c3827f2c18180533b804ebd4d8f5cb90774244b.tar.xz
Enable addtional flake8-bugbear linting checks. (#9659)
Diffstat (limited to '')
-rw-r--r--changelog.d/9659.misc1
-rw-r--r--setup.cfg4
-rw-r--r--synapse/crypto/context_factory.py2
-rw-r--r--synapse/logging/context.py2
-rw-r--r--synapse/storage/database.py2
-rw-r--r--synapse/util/async_helpers.py2
-rw-r--r--synapse/util/caches/__init__.py2
-rw-r--r--tests/server.py2
8 files changed, 9 insertions, 8 deletions
diff --git a/changelog.d/9659.misc b/changelog.d/9659.misc
new file mode 100644
index 0000000000..6602c1cc6a
--- /dev/null
+++ b/changelog.d/9659.misc
@@ -0,0 +1 @@
+Introduce bugbear to the test suite and fix some of it's lint violations.
diff --git a/setup.cfg b/setup.cfg
index 920868df20..7329eed213 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,8 +18,8 @@ ignore =
 #  E203: whitespace before ':' (which is contrary to pep8?)
 #  E731: do not assign a lambda expression, use a def
 #  E501: Line too long (black enforces this for us)
-#   B00: Subsection of the bugbear suite (TODO: add in remaining fixes)
-ignore=W503,W504,E203,E731,E501,B00
+#  B00*: Subsection of the bugbear suite (TODO: add in remaining fixes)
+ignore=W503,W504,E203,E731,E501,B006,B007,B008
 
 [isort]
 line_length = 88
diff --git a/synapse/crypto/context_factory.py b/synapse/crypto/context_factory.py
index 4ca13011e5..c644b4dfc5 100644
--- a/synapse/crypto/context_factory.py
+++ b/synapse/crypto/context_factory.py
@@ -191,7 +191,7 @@ def _context_info_cb(ssl_connection, where, ret):
         # ... we further assume that SSLClientConnectionCreator has set the
         # '_synapse_tls_verifier' attribute to a ConnectionVerifier object.
         tls_protocol._synapse_tls_verifier.verify_context_info_cb(ssl_connection, where)
-    except:  # noqa: E722, taken from the twisted implementation
+    except BaseException:  # taken from the twisted implementation
         logger.exception("Error during info_callback")
         f = Failure()
         tls_protocol.failVerification(f)
diff --git a/synapse/logging/context.py b/synapse/logging/context.py
index 1a7ea4fa96..03cf3c2b8e 100644
--- a/synapse/logging/context.py
+++ b/synapse/logging/context.py
@@ -689,7 +689,7 @@ def run_in_background(f, *args, **kwargs) -> defer.Deferred:
     current = current_context()
     try:
         res = f(*args, **kwargs)
-    except:  # noqa: E722
+    except Exception:
         # the assumption here is that the caller doesn't want to be disturbed
         # by synchronous exceptions, so let's turn them into Failures.
         return defer.fail()
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index f1ba529a2d..5b0b9a20bf 100644
--- a/synapse/storage/database.py
+++ b/synapse/storage/database.py
@@ -670,7 +670,7 @@ class DatabasePool:
 
             for after_callback, after_args, after_kwargs in after_callbacks:
                 after_callback(*after_args, **after_kwargs)
-        except:  # noqa: E722, as we reraise the exception this is fine.
+        except Exception:
             for after_callback, after_args, after_kwargs in exception_callbacks:
                 after_callback(*after_args, **after_kwargs)
             raise
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py
index f33c115844..c3b2d981ea 100644
--- a/synapse/util/async_helpers.py
+++ b/synapse/util/async_helpers.py
@@ -496,7 +496,7 @@ def timeout_deferred(
 
         try:
             deferred.cancel()
-        except:  # noqa: E722, if we throw any exception it'll break time outs
+        except Exception:  # if we throw any exception it'll break time outs
             logger.exception("Canceller failed during timeout")
 
         # the cancel() call should have set off a chain of errbacks which
diff --git a/synapse/util/caches/__init__.py b/synapse/util/caches/__init__.py
index e676c2cac4..f968706334 100644
--- a/synapse/util/caches/__init__.py
+++ b/synapse/util/caches/__init__.py
@@ -116,7 +116,7 @@ def register_cache(
     """
     if resizable:
         if not resize_callback:
-            resize_callback = getattr(cache, "set_cache_factor")
+            resize_callback = cache.set_cache_factor  # type: ignore
         add_resizable_cache(cache_name, resize_callback)
 
     metric = CacheMetric(cache, cache_type, cache_name, collect_callback)
diff --git a/tests/server.py b/tests/server.py
index 2287d20076..57cc4ac605 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -593,7 +593,7 @@ class FakeTransport:
         if self.disconnected:
             return
 
-        if getattr(self.other, "transport") is None:
+        if not hasattr(self.other, "transport"):
             # the other has no transport yet; reschedule
             if self.autoflush:
                 self._reactor.callLater(0.0, self.flush)