mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 03:44:56 -04:00
Type hints for the remaining two files in synapse.http
. (#11164)
* Teach MyPy that the sentinel context is False This means that if `ctx: LoggingContextOrSentinel` then `bool(ctx)` narrows us to `ctx:LoggingContext`, which is a really neat find! * Annotate RequestMetrics - Raise errors for sentry if we use the sentinel context - Ensure we don't raise an error and carry on, but not recording stats - Include stack trace in the error case to lower Sean's blood pressure * Make mypy pass for synapse.http.request_metrics * Make synapse.http.connectproxyclient pass mypy Co-authored-by: reivilibre <oliverw@matrix.org>
This commit is contained in:
parent
a19bf32a03
commit
1bfd141205
6 changed files with 56 additions and 37 deletions
|
@ -220,7 +220,7 @@ class _Sentinel:
|
|||
self.scope = None
|
||||
self.tag = None
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return "sentinel"
|
||||
|
||||
def copy_to(self, record):
|
||||
|
@ -241,7 +241,7 @@ class _Sentinel:
|
|||
def record_event_fetch(self, event_count):
|
||||
pass
|
||||
|
||||
def __bool__(self):
|
||||
def __bool__(self) -> Literal[False]:
|
||||
return False
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue