mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 16:34:49 -04:00
Add type hints to filtering classes. (#10958)
This commit is contained in:
parent
9e5a429c8b
commit
7e440520c9
3 changed files with 81 additions and 45 deletions
|
@ -12,6 +12,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import Union
|
||||
|
||||
from canonicaljson import encode_canonical_json
|
||||
|
||||
from synapse.api.errors import Codes, SynapseError
|
||||
|
@ -22,7 +24,9 @@ from synapse.util.caches.descriptors import cached
|
|||
|
||||
class FilteringStore(SQLBaseStore):
|
||||
@cached(num_args=2)
|
||||
async def get_user_filter(self, user_localpart, filter_id):
|
||||
async def get_user_filter(
|
||||
self, user_localpart: str, filter_id: Union[int, str]
|
||||
) -> JsonDict:
|
||||
# filter_id is BIGINT UNSIGNED, so if it isn't a number, fail
|
||||
# with a coherent error message rather than 500 M_UNKNOWN.
|
||||
try:
|
||||
|
@ -40,7 +44,7 @@ class FilteringStore(SQLBaseStore):
|
|||
|
||||
return db_to_json(def_json)
|
||||
|
||||
async def add_user_filter(self, user_localpart: str, user_filter: JsonDict) -> str:
|
||||
async def add_user_filter(self, user_localpart: str, user_filter: JsonDict) -> int:
|
||||
def_json = encode_canonical_json(user_filter)
|
||||
|
||||
# Need an atomic transaction to SELECT the maximal ID so far then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue