Use inline type hints in various other places (in synapse/) (#10380)

This commit is contained in:
Jonathan de Jong 2021-07-15 12:02:43 +02:00 committed by GitHub
parent c7603af1d0
commit bf72d10dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 329 additions and 336 deletions

View file

@ -251,7 +251,7 @@ try:
except Exception:
logger.exception("Failed to report span")
RustReporter = _WrappedRustReporter # type: Optional[Type[_WrappedRustReporter]]
RustReporter: Optional[Type[_WrappedRustReporter]] = _WrappedRustReporter
except ImportError:
RustReporter = None
@ -286,7 +286,7 @@ class SynapseBaggage:
# Block everything by default
# A regex which matches the server_names to expose traces for.
# None means 'block everything'.
_homeserver_whitelist = None # type: Optional[Pattern[str]]
_homeserver_whitelist: Optional[Pattern[str]] = None
# Util methods
@ -662,7 +662,7 @@ def inject_header_dict(
span = opentracing.tracer.active_span
carrier = {} # type: Dict[str, str]
carrier: Dict[str, str] = {}
opentracing.tracer.inject(span.context, opentracing.Format.HTTP_HEADERS, carrier)
for key, value in carrier.items():
@ -704,7 +704,7 @@ def get_active_span_text_map(destination=None):
if destination and not whitelisted_homeserver(destination):
return {}
carrier = {} # type: Dict[str, str]
carrier: Dict[str, str] = {}
opentracing.tracer.inject(
opentracing.tracer.active_span.context, opentracing.Format.TEXT_MAP, carrier
)
@ -718,7 +718,7 @@ def active_span_context_as_string():
Returns:
The active span context encoded as a string.
"""
carrier = {} # type: Dict[str, str]
carrier: Dict[str, str] = {}
if opentracing:
opentracing.tracer.inject(
opentracing.tracer.active_span.context, opentracing.Format.TEXT_MAP, carrier