This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '208e1d3eb' into anoa/dinsic_release_1_21_x
* commit '208e1d3eb': Fix typing for `@cached` wrapped functions (#8240) Remove useless changelog about reverting a #8239. Revert pinning of setuptools (#8239) Fix typing for SyncHandler (#8237) wrap `_get_e2e_device_keys_and_signatures_txn` in a non-txn method (#8231) Add an overload for simple_select_one_onecol_txn. (#8235)
- Loading branch information
Showing
17 changed files
with
200 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Refactor queries for device keys and cross-signatures. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add type hints to `StreamStore`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix type hints in `SyncHandler`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix type hints for functions decorated with `@cached`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 The Matrix.org Foundation C.I.C. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""This is a mypy plugin for Synpase to deal with some of the funky typing that | ||
can crop up, e.g the cache descriptors. | ||
""" | ||
|
||
from typing import Callable, Optional | ||
|
||
from mypy.plugin import MethodSigContext, Plugin | ||
from mypy.typeops import bind_self | ||
from mypy.types import CallableType | ||
|
||
|
||
class SynapsePlugin(Plugin): | ||
def get_method_signature_hook( | ||
self, fullname: str | ||
) -> Optional[Callable[[MethodSigContext], CallableType]]: | ||
if fullname.startswith( | ||
"synapse.util.caches.descriptors._CachedFunction.__call__" | ||
): | ||
return cached_function_method_signature | ||
return None | ||
|
||
|
||
def cached_function_method_signature(ctx: MethodSigContext) -> CallableType: | ||
"""Fixes the `_CachedFunction.__call__` signature to be correct. | ||
It already has *almost* the correct signature, except: | ||
1. the `self` argument needs to be marked as "bound"; and | ||
2. any `cache_context` argument should be removed. | ||
""" | ||
|
||
# First we mark this as a bound function signature. | ||
signature = bind_self(ctx.default_signature) | ||
|
||
# Secondly, we remove any "cache_context" args. | ||
# | ||
# Note: We should be only doing this if `cache_context=True` is set, but if | ||
# it isn't then the code will raise an exception when its called anyway, so | ||
# its not the end of the world. | ||
context_arg_index = None | ||
for idx, name in enumerate(signature.arg_names): | ||
if name == "cache_context": | ||
context_arg_index = idx | ||
break | ||
|
||
if context_arg_index: | ||
arg_types = list(signature.arg_types) | ||
arg_types.pop(context_arg_index) | ||
|
||
arg_names = list(signature.arg_names) | ||
arg_names.pop(context_arg_index) | ||
|
||
arg_kinds = list(signature.arg_kinds) | ||
arg_kinds.pop(context_arg_index) | ||
|
||
signature = signature.copy_modified( | ||
arg_types=arg_types, arg_names=arg_names, arg_kinds=arg_kinds, | ||
) | ||
|
||
return signature | ||
|
||
|
||
def plugin(version: str): | ||
# This is the entry point of the plugin, and let's us deal with the fact | ||
# that the mypy plugin interface is *not* stable by looking at the version | ||
# string. | ||
# | ||
# However, since we pin the version of mypy Synapse uses in CI, we don't | ||
# really care. | ||
return SynapsePlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.