mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 16:34:49 -04:00
Remove redundant types from comments. (#14412)
Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
This commit is contained in:
parent
882277008c
commit
d8cc86eff4
55 changed files with 174 additions and 176 deletions
|
@ -117,8 +117,7 @@ class ContextResourceUsage:
|
|||
"""Create a new ContextResourceUsage
|
||||
|
||||
Args:
|
||||
copy_from (ContextResourceUsage|None): if not None, an object to
|
||||
copy stats from
|
||||
copy_from: if not None, an object to copy stats from
|
||||
"""
|
||||
if copy_from is None:
|
||||
self.reset()
|
||||
|
@ -162,7 +161,7 @@ class ContextResourceUsage:
|
|||
"""Add another ContextResourceUsage's stats to this one's.
|
||||
|
||||
Args:
|
||||
other (ContextResourceUsage): the other resource usage object
|
||||
other: the other resource usage object
|
||||
"""
|
||||
self.ru_utime += other.ru_utime
|
||||
self.ru_stime += other.ru_stime
|
||||
|
@ -342,7 +341,7 @@ class LoggingContext:
|
|||
called directly.
|
||||
|
||||
Returns:
|
||||
LoggingContext: the current logging context
|
||||
The current logging context
|
||||
"""
|
||||
warnings.warn(
|
||||
"synapse.logging.context.LoggingContext.current_context() is deprecated "
|
||||
|
@ -362,7 +361,8 @@ class LoggingContext:
|
|||
called directly.
|
||||
|
||||
Args:
|
||||
context(LoggingContext): The context to activate.
|
||||
context: The context to activate.
|
||||
|
||||
Returns:
|
||||
The context that was previously active
|
||||
"""
|
||||
|
@ -474,8 +474,7 @@ class LoggingContext:
|
|||
"""Get resources used by this logcontext so far.
|
||||
|
||||
Returns:
|
||||
ContextResourceUsage: a *copy* of the object tracking resource
|
||||
usage so far
|
||||
A *copy* of the object tracking resource usage so far
|
||||
"""
|
||||
# we always return a copy, for consistency
|
||||
res = self._resource_usage.copy()
|
||||
|
@ -663,7 +662,8 @@ def current_context() -> LoggingContextOrSentinel:
|
|||
def set_current_context(context: LoggingContextOrSentinel) -> LoggingContextOrSentinel:
|
||||
"""Set the current logging context in thread local storage
|
||||
Args:
|
||||
context(LoggingContext): The context to activate.
|
||||
context: The context to activate.
|
||||
|
||||
Returns:
|
||||
The context that was previously active
|
||||
"""
|
||||
|
@ -700,7 +700,7 @@ def nested_logging_context(suffix: str) -> LoggingContext:
|
|||
suffix: suffix to add to the parent context's 'name'.
|
||||
|
||||
Returns:
|
||||
LoggingContext: new logging context.
|
||||
A new logging context.
|
||||
"""
|
||||
curr_context = current_context()
|
||||
if not curr_context:
|
||||
|
@ -898,20 +898,19 @@ def defer_to_thread(
|
|||
on it.
|
||||
|
||||
Args:
|
||||
reactor (twisted.internet.base.ReactorBase): The reactor in whose main thread
|
||||
the Deferred will be invoked, and whose threadpool we should use for the
|
||||
function.
|
||||
reactor: The reactor in whose main thread the Deferred will be invoked,
|
||||
and whose threadpool we should use for the function.
|
||||
|
||||
Normally this will be hs.get_reactor().
|
||||
|
||||
f (callable): The function to call.
|
||||
f: The function to call.
|
||||
|
||||
args: positional arguments to pass to f.
|
||||
|
||||
kwargs: keyword arguments to pass to f.
|
||||
|
||||
Returns:
|
||||
Deferred: A Deferred which fires a callback with the result of `f`, or an
|
||||
A Deferred which fires a callback with the result of `f`, or an
|
||||
errback if `f` throws an exception.
|
||||
"""
|
||||
return defer_to_threadpool(reactor, reactor.getThreadPool(), f, *args, **kwargs)
|
||||
|
@ -939,20 +938,20 @@ def defer_to_threadpool(
|
|||
on it.
|
||||
|
||||
Args:
|
||||
reactor (twisted.internet.base.ReactorBase): The reactor in whose main thread
|
||||
the Deferred will be invoked. Normally this will be hs.get_reactor().
|
||||
reactor: The reactor in whose main thread the Deferred will be invoked.
|
||||
Normally this will be hs.get_reactor().
|
||||
|
||||
threadpool (twisted.python.threadpool.ThreadPool): The threadpool to use for
|
||||
running `f`. Normally this will be hs.get_reactor().getThreadPool().
|
||||
threadpool: The threadpool to use for running `f`. Normally this will be
|
||||
hs.get_reactor().getThreadPool().
|
||||
|
||||
f (callable): The function to call.
|
||||
f: The function to call.
|
||||
|
||||
args: positional arguments to pass to f.
|
||||
|
||||
kwargs: keyword arguments to pass to f.
|
||||
|
||||
Returns:
|
||||
Deferred: A Deferred which fires a callback with the result of `f`, or an
|
||||
A Deferred which fires a callback with the result of `f`, or an
|
||||
errback if `f` throws an exception.
|
||||
"""
|
||||
curr_context = current_context()
|
||||
|
|
|
@ -721,7 +721,7 @@ def inject_header_dict(
|
|||
destination: address of entity receiving the span context. Must be given unless
|
||||
check_destination is False. The context will only be injected if the
|
||||
destination matches the opentracing whitelist
|
||||
check_destination (bool): If false, destination will be ignored and the context
|
||||
check_destination: If false, destination will be ignored and the context
|
||||
will always be injected.
|
||||
|
||||
Note:
|
||||
|
@ -780,7 +780,7 @@ def get_active_span_text_map(destination: Optional[str] = None) -> Dict[str, str
|
|||
destination: the name of the remote server.
|
||||
|
||||
Returns:
|
||||
dict: the active span's context if opentracing is enabled, otherwise empty.
|
||||
the active span's context if opentracing is enabled, otherwise empty.
|
||||
"""
|
||||
|
||||
if destination and not whitelisted_homeserver(destination):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue