Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
8eaffe01
Unverified
Commit
8eaffe01
authored
3 years ago
by
Sean Quah
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update `_wrap_in_base_path` type hints to preserve function arguments (#11055)
parent
77ea0308
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/11055.misc
+1
-0
1 addition, 0 deletions
changelog.d/11055.misc
synapse/rest/media/v1/filepath.py
+6
-3
6 additions, 3 deletions
synapse/rest/media/v1/filepath.py
with
7 additions
and
3 deletions
changelog.d/11055.misc
0 → 100644
+
1
−
0
View file @
8eaffe01
Improve type hints for `_wrap_in_base_path` decorator used by `MediaFilePaths`.
This diff is collapsed.
Click to expand it.
synapse/rest/media/v1/filepath.py
+
6
−
3
View file @
8eaffe01
...
...
@@ -16,12 +16,15 @@
import
functools
import
os
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
"
)
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
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
)
return
os
.
path
.
join
(
self
.
base_path
,
path
)
return
_wrapped
return
cast
(
F
,
_wrapped
)
class
MediaFilePaths
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment