Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
a1901abd
"docs/reverse_proxy.rst" did not exist on "6cd11109db27232d5671d14def4be88646df28d9"
Unverified
Commit
a1901abd
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation and type hints to parse_duration. (#9432)
parent
c4a55ac4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/9432.misc
+1
-0
1 addition, 0 deletions
changelog.d/9432.misc
synapse/config/_base.py
+15
-2
15 additions, 2 deletions
synapse/config/_base.py
with
16 additions
and
2 deletions
changelog.d/9432.misc
0 → 100644
+
1
−
0
View file @
a1901abd
Add documentation and type hints to `parse_duration`.
This diff is collapsed.
Click to expand it.
synapse/config/_base.py
+
15
−
2
View file @
a1901abd
...
...
@@ -21,7 +21,7 @@ import os
from
collections
import
OrderedDict
from
hashlib
import
sha256
from
textwrap
import
dedent
from
typing
import
Any
,
Iterable
,
List
,
MutableMapping
,
Optional
from
typing
import
Any
,
Iterable
,
List
,
MutableMapping
,
Optional
,
Union
import
attr
import
jinja2
...
...
@@ -147,7 +147,20 @@ class Config:
return
int
(
value
)
*
size
@staticmethod
def
parse_duration
(
value
):
def
parse_duration
(
value
:
Union
[
str
,
int
])
->
int
:
"""
Convert a duration as a string or integer to a number of milliseconds.
If an integer is provided it is treated as milliseconds and is unchanged.
String durations can have a suffix of
'
s
'
,
'
m
'
,
'
h
'
,
'
d
'
,
'
w
'
, or
'
y
'
.
No suffix is treated as milliseconds.
Args:
value: The duration to parse.
Returns:
The number of milliseconds in the duration.
"""
if
isinstance
(
value
,
int
):
return
value
second
=
1000
...
...
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