mirror of
https://github.com/matrix-org/synapse.git
synced 2025-02-06 23:35:47 +00:00
Update _wrap_in_base_path
type hints to preserve function arguments (#11055)
This commit is contained in:
parent
77ea03086c
commit
8eaffe013c
1
changelog.d/11055.misc
Normal file
1
changelog.d/11055.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Improve type hints for `_wrap_in_base_path` decorator used by `MediaFilePaths`.
|
@ -16,12 +16,15 @@
|
|||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from typing import Any, Callable, List
|
from typing import Any, Callable, List, TypeVar, cast
|
||||||
|
|
||||||
NEW_FORMAT_ID_RE = re.compile(r"^\d\d\d\d-\d\d-\d\d")
|
NEW_FORMAT_ID_RE = re.compile(r"^\d\d\d\d-\d\d-\d\d")
|
||||||
|
|
||||||
|
|
||||||
def _wrap_in_base_path(func: Callable[..., str]) -> Callable[..., str]:
|
F = TypeVar("F", bound=Callable[..., str])
|
||||||
|
|
||||||
|
|
||||||
|
def _wrap_in_base_path(func: F) -> F:
|
||||||
"""Takes a function that returns a relative path and turns it into an
|
"""Takes a function that returns a relative path and turns it into an
|
||||||
absolute path based on the location of the primary media store
|
absolute path based on the location of the primary media store
|
||||||
"""
|
"""
|
||||||
@ -31,7 +34,7 @@ def _wrap_in_base_path(func: Callable[..., str]) -> Callable[..., str]:
|
|||||||
path = func(self, *args, **kwargs)
|
path = func(self, *args, **kwargs)
|
||||||
return os.path.join(self.base_path, path)
|
return os.path.join(self.base_path, path)
|
||||||
|
|
||||||
return _wrapped
|
return cast(F, _wrapped)
|
||||||
|
|
||||||
|
|
||||||
class MediaFilePaths:
|
class MediaFilePaths:
|
||||||
|
Loading…
Reference in New Issue
Block a user