Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix additional type hints #9543

Merged
merged 9 commits into from
Mar 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion synapse/logging/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def g(*args, **kwargs):
return g


def run_in_background(f, *args, **kwargs):
def run_in_background(f, *args, **kwargs) -> defer.Deferred:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't 100% true actually since if the result is not a Deferred than we return it raw, which seems confusing. I think we should likely wrap that in defer.succeed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably. I don't think we should lie about our return value here.

Copy link
Member Author

@clokep clokep Mar 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrapped the raw return value in defer.succeed, I suspect it doesn't really make sense to call run_in_background with a sync function, but 🤷 This would have also broke when using await, so maybe we should make this an error instead?

"""Calls a function, ensuring that the current context is restored after
return from the function, and that the sentinel context is set once the
deferred returned by the function completes.
Expand Down