This repository was 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
[pyupgrade] synapse/
#10348
Merged
erikjohnston
merged 3 commits into
matrix-org:develop
from
ShadowJonathan:pyupgrade/synapse
Jul 19, 2021
Merged
[pyupgrade] synapse/
#10348
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
Run `pyupgrade` on the codebase. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
|
||
from synapse.util import caches | ||
|
||
CONTENT_TYPE_LATEST = str("text/plain; version=0.0.4; charset=utf-8") | ||
CONTENT_TYPE_LATEST = "text/plain; version=0.0.4; charset=utf-8" | ||
|
||
|
||
INF = float("inf") | ||
|
@@ -55,8 +55,8 @@ def floatToGoString(d): | |
# Go switches to exponents sooner than Python. | ||
# We only need to care about positive values for le/quantile. | ||
if d > 0 and dot > 6: | ||
mantissa = "{0}.{1}{2}".format(s[0], s[1:dot], s[dot + 1 :]).rstrip("0.") | ||
return "{0}e+0{1}".format(mantissa, dot - 1) | ||
mantissa = f"{s[0]}.{s[1:dot]}{s[dot + 1 :]}".rstrip("0.") | ||
return f"{mantissa}e+0{dot - 1}" | ||
return s | ||
|
||
|
||
|
@@ -65,7 +65,7 @@ def sample_line(line, name): | |
labelstr = "{{{0}}}".format( | ||
",".join( | ||
[ | ||
'{0}="{1}"'.format( | ||
'{}="{}"'.format( | ||
k, | ||
v.replace("\\", r"\\").replace("\n", r"\n").replace('"', r"\""), | ||
) | ||
|
@@ -78,10 +78,8 @@ def sample_line(line, name): | |
timestamp = "" | ||
if line.timestamp is not None: | ||
# Convert to milliseconds. | ||
timestamp = " {0:d}".format(int(float(line.timestamp) * 1000)) | ||
return "{0}{1} {2}{3}\n".format( | ||
name, labelstr, floatToGoString(line.value), timestamp | ||
) | ||
timestamp = f" {int(float(line.timestamp) * 1000):d}" | ||
return "{}{} {}{}\n".format(name, labelstr, floatToGoString(line.value), timestamp) | ||
|
||
|
||
def generate_latest(registry, emit_help=False): | ||
|
@@ -118,12 +116,12 @@ def generate_latest(registry, emit_help=False): | |
# Output in the old format for compatibility. | ||
if emit_help: | ||
output.append( | ||
"# HELP {0} {1}\n".format( | ||
"# HELP {} {}\n".format( | ||
mname, | ||
metric.documentation.replace("\\", r"\\").replace("\n", r"\n"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a note; |
||
) | ||
) | ||
output.append("# TYPE {0} {1}\n".format(mname, mtype)) | ||
output.append(f"# TYPE {mname} {mtype}\n") | ||
|
||
om_samples = {} # type: Dict[str, List[str]] | ||
for s in metric.samples: | ||
|
@@ -143,13 +141,13 @@ def generate_latest(registry, emit_help=False): | |
for suffix, lines in sorted(om_samples.items()): | ||
if emit_help: | ||
output.append( | ||
"# HELP {0}{1} {2}\n".format( | ||
"# HELP {}{} {}\n".format( | ||
metric.name, | ||
suffix, | ||
metric.documentation.replace("\\", r"\\").replace("\n", r"\n"), | ||
) | ||
) | ||
output.append("# TYPE {0}{1} gauge\n".format(metric.name, suffix)) | ||
output.append(f"# TYPE {metric.name}{suffix} gauge\n") | ||
output.extend(lines) | ||
|
||
# Get rid of the weird colon things while we're at it | ||
|
@@ -163,12 +161,12 @@ def generate_latest(registry, emit_help=False): | |
# Also output in the new format, if it's different. | ||
if emit_help: | ||
output.append( | ||
"# HELP {0} {1}\n".format( | ||
"# HELP {} {}\n".format( | ||
mnewname, | ||
metric.documentation.replace("\\", r"\\").replace("\n", r"\n"), | ||
) | ||
) | ||
output.append("# TYPE {0} {1}\n".format(mnewname, mtype)) | ||
output.append(f"# TYPE {mnewname} {mtype}\n") | ||
|
||
for s in metric.samples: | ||
# Get rid of the OpenMetrics specific samples (we should already have | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.