mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Enable addtional flake8-bugbear linting checks. (#9659)
This commit is contained in:
parent
c73cc2c2ad
commit
4c3827f2c1
1
changelog.d/9659.misc
Normal file
1
changelog.d/9659.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Introduce bugbear to the test suite and fix some of it's lint violations.
|
@ -18,8 +18,8 @@ ignore =
|
|||||||
# E203: whitespace before ':' (which is contrary to pep8?)
|
# E203: whitespace before ':' (which is contrary to pep8?)
|
||||||
# E731: do not assign a lambda expression, use a def
|
# E731: do not assign a lambda expression, use a def
|
||||||
# E501: Line too long (black enforces this for us)
|
# E501: Line too long (black enforces this for us)
|
||||||
# B00: Subsection of the bugbear suite (TODO: add in remaining fixes)
|
# B00*: Subsection of the bugbear suite (TODO: add in remaining fixes)
|
||||||
ignore=W503,W504,E203,E731,E501,B00
|
ignore=W503,W504,E203,E731,E501,B006,B007,B008
|
||||||
|
|
||||||
[isort]
|
[isort]
|
||||||
line_length = 88
|
line_length = 88
|
||||||
|
@ -191,7 +191,7 @@ def _context_info_cb(ssl_connection, where, ret):
|
|||||||
# ... we further assume that SSLClientConnectionCreator has set the
|
# ... we further assume that SSLClientConnectionCreator has set the
|
||||||
# '_synapse_tls_verifier' attribute to a ConnectionVerifier object.
|
# '_synapse_tls_verifier' attribute to a ConnectionVerifier object.
|
||||||
tls_protocol._synapse_tls_verifier.verify_context_info_cb(ssl_connection, where)
|
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")
|
logger.exception("Error during info_callback")
|
||||||
f = Failure()
|
f = Failure()
|
||||||
tls_protocol.failVerification(f)
|
tls_protocol.failVerification(f)
|
||||||
|
@ -689,7 +689,7 @@ def run_in_background(f, *args, **kwargs) -> defer.Deferred:
|
|||||||
current = current_context()
|
current = current_context()
|
||||||
try:
|
try:
|
||||||
res = f(*args, **kwargs)
|
res = f(*args, **kwargs)
|
||||||
except: # noqa: E722
|
except Exception:
|
||||||
# the assumption here is that the caller doesn't want to be disturbed
|
# the assumption here is that the caller doesn't want to be disturbed
|
||||||
# by synchronous exceptions, so let's turn them into Failures.
|
# by synchronous exceptions, so let's turn them into Failures.
|
||||||
return defer.fail()
|
return defer.fail()
|
||||||
|
@ -670,7 +670,7 @@ class DatabasePool:
|
|||||||
|
|
||||||
for after_callback, after_args, after_kwargs in after_callbacks:
|
for after_callback, after_args, after_kwargs in after_callbacks:
|
||||||
after_callback(*after_args, **after_kwargs)
|
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:
|
for after_callback, after_args, after_kwargs in exception_callbacks:
|
||||||
after_callback(*after_args, **after_kwargs)
|
after_callback(*after_args, **after_kwargs)
|
||||||
raise
|
raise
|
||||||
|
@ -496,7 +496,7 @@ def timeout_deferred(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
deferred.cancel()
|
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")
|
logger.exception("Canceller failed during timeout")
|
||||||
|
|
||||||
# the cancel() call should have set off a chain of errbacks which
|
# the cancel() call should have set off a chain of errbacks which
|
||||||
|
@ -116,7 +116,7 @@ def register_cache(
|
|||||||
"""
|
"""
|
||||||
if resizable:
|
if resizable:
|
||||||
if not resize_callback:
|
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)
|
add_resizable_cache(cache_name, resize_callback)
|
||||||
|
|
||||||
metric = CacheMetric(cache, cache_type, cache_name, collect_callback)
|
metric = CacheMetric(cache, cache_type, cache_name, collect_callback)
|
||||||
|
@ -593,7 +593,7 @@ class FakeTransport:
|
|||||||
if self.disconnected:
|
if self.disconnected:
|
||||||
return
|
return
|
||||||
|
|
||||||
if getattr(self.other, "transport") is None:
|
if not hasattr(self.other, "transport"):
|
||||||
# the other has no transport yet; reschedule
|
# the other has no transport yet; reschedule
|
||||||
if self.autoflush:
|
if self.autoflush:
|
||||||
self._reactor.callLater(0.0, self.flush)
|
self._reactor.callLater(0.0, self.flush)
|
||||||
|
Loading…
Reference in New Issue
Block a user