Skip to content

Commit 45475a7

Browse files
authored
pyupgrade --py36-plus **/*.py (#112)
1 parent d47ed53 commit 45475a7

File tree

9 files changed

+22
-29
lines changed

9 files changed

+22
-29
lines changed

pylib/gyp/MSVSUtil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _SuffixName(name, suffix):
5555
Target name with suffix added (foo_suffix#target)
5656
"""
5757
parts = name.rsplit("#", 1)
58-
parts[0] = "{}_{}".format(parts[0], suffix)
58+
parts[0] = f"{parts[0]}_{suffix}"
5959
return "#".join(parts)
6060

6161

pylib/gyp/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def pop(self, last=True): # pylint: disable=W0221
562562
def __repr__(self):
563563
if not self:
564564
return f"{self.__class__.__name__}()"
565-
return "{}({!r})".format(self.__class__.__name__, list(self))
565+
return f"{self.__class__.__name__}({list(self)!r})"
566566

567567
def __eq__(self, other):
568568
if isinstance(other, OrderedSet):

pylib/gyp/easy_xml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
8585
rest = specification[1:]
8686
if rest and isinstance(rest[0], dict):
8787
for at, val in sorted(rest[0].items()):
88-
xml_parts.append(' {}="{}"'.format(at, _XmlEscape(val, attr=True)))
88+
xml_parts.append(f' {at}="{_XmlEscape(val, attr=True)}"')
8989
rest = rest[1:]
9090
if rest:
9191
xml_parts.append(">")

pylib/gyp/generator/android.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs):
349349
for output in outputs[1:]:
350350
# Make each output depend on the main output, with an empty command
351351
# to force make to notice that the mtime has changed.
352-
self.WriteLn("{}: {} ;".format(self.LocalPathify(output), main_output))
352+
self.WriteLn(f"{self.LocalPathify(output)}: {main_output} ;")
353353

354354
extra_outputs += outputs
355355
self.WriteLn()
@@ -616,7 +616,7 @@ def WriteSources(self, spec, configs, extra_sources):
616616
if IsCPPExtension(ext) and ext != local_cpp_extension:
617617
local_file = root + local_cpp_extension
618618
if local_file != source:
619-
self.WriteLn("{}: {}".format(local_file, self.LocalPathify(source)))
619+
self.WriteLn(f"{local_file}: {self.LocalPathify(source)}")
620620
self.WriteLn("\tmkdir -p $(@D); cp $< $@")
621621
origin_src_dirs.append(os.path.dirname(source))
622622
final_generated_sources.append(local_file)
@@ -908,7 +908,7 @@ def WriteTarget(
908908
if isinstance(v, list):
909909
self.WriteList(v, k)
910910
else:
911-
self.WriteLn("{} := {}".format(k, make.QuoteIfNecessary(v)))
911+
self.WriteLn(f"{k} := {make.QuoteIfNecessary(v)}")
912912
self.WriteLn("")
913913

914914
# Add to the set of targets which represent the gyp 'all' target. We use the

pylib/gyp/generator/make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ def WriteSortedXcodeEnv(self, target, env):
21332133
# export foo := a\ b
21342134
# it does not -- the backslash is written to the env as literal character.
21352135
# So don't escape spaces in |env[k]|.
2136-
self.WriteLn("{}: export {} := {}".format(QuoteSpaces(target), k, v))
2136+
self.WriteLn(f"{QuoteSpaces(target)}: export {k} := {v}")
21372137

21382138
def Objectify(self, path):
21392139
"""Convert a path to its output directory form."""

pylib/gyp/generator/msvs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _ConfigBaseName(config_name, platform_name):
314314

315315
def _ConfigFullName(config_name, config_data):
316316
platform_name = _ConfigPlatform(config_data)
317-
return "{}|{}".format(_ConfigBaseName(config_name, platform_name), platform_name)
317+
return f"{_ConfigBaseName(config_name, platform_name)}|{platform_name}"
318318

319319

320320
def _ConfigWindowsTargetPlatformVersion(config_data, version):
@@ -335,15 +335,15 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
335335
# Find a matching entry in sdk_dir\include.
336336
expected_sdk_dir = r"%s\include" % sdk_dir
337337
names = sorted(
338-
[
338+
(
339339
x
340340
for x in (
341341
os.listdir(expected_sdk_dir)
342342
if os.path.isdir(expected_sdk_dir)
343343
else []
344344
)
345345
if x.startswith(version)
346-
],
346+
),
347347
reverse=True,
348348
)
349349
if names:

pylib/gyp/generator/ninja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def GenerateDescription(self, verb, message, fallback):
638638
if self.toolset != "target":
639639
verb += "(%s)" % self.toolset
640640
if message:
641-
return "{} {}".format(verb, self.ExpandSpecial(message))
641+
return f"{verb} {self.ExpandSpecial(message)}"
642642
else:
643643
return f"{verb} {self.name}: {fallback}"
644644

pylib/gyp/xcodeproj_file.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ def __repr__(self):
299299
try:
300300
name = self.Name()
301301
except NotImplementedError:
302-
return "<{} at 0x{:x}>".format(self.__class__.__name__, id(self))
303-
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
302+
return f"<{self.__class__.__name__} at 0x{id(self):x}>"
303+
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"
304304

305305
def Copy(self):
306306
"""Make a copy of this object.
@@ -2251,7 +2251,7 @@ class PBXContainerItemProxy(XCObject):
22512251
def __repr__(self):
22522252
props = self._properties
22532253
name = "{}.gyp:{}".format(props["containerPortal"].Name(), props["remoteInfo"])
2254-
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
2254+
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"
22552255

22562256
def Name(self):
22572257
# Admittedly not the best name, but it's what Xcode uses.
@@ -2288,7 +2288,7 @@ class PBXTargetDependency(XCObject):
22882288

22892289
def __repr__(self):
22902290
name = self._properties.get("name") or self._properties["target"].Name()
2291-
return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self))
2291+
return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>"
22922292

22932293
def Name(self):
22942294
# Admittedly not the best name, but it's what Xcode uses.

test_gyp.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ def main(argv=None):
140140
if not args.quiet:
141141
runner.print_results()
142142

143-
if runner.failures:
144-
return 1
145-
else:
146-
return 0
143+
return 1 if runner.failures else 0
147144

148145

149146
def print_configuration_info():
@@ -152,8 +149,8 @@ def print_configuration_info():
152149
sys.path.append(os.path.abspath("test/lib"))
153150
import TestMac
154151

155-
print(" Mac {} {}".format(platform.mac_ver()[0], platform.mac_ver()[2]))
156-
print(" Xcode %s" % TestMac.Xcode.Version())
152+
print(f" Mac {platform.mac_ver()[0]} {platform.mac_ver()[2]}")
153+
print(f" Xcode {TestMac.Xcode.Version()}")
157154
elif sys.platform == "win32":
158155
sys.path.append(os.path.abspath("pylib"))
159156
import gyp.MSVSVersion
@@ -162,8 +159,8 @@ def print_configuration_info():
162159
print(" MSVS %s" % gyp.MSVSVersion.SelectVisualStudioVersion().Description())
163160
elif sys.platform in ("linux", "linux2"):
164161
print(" Linux %s" % " ".join(platform.linux_distribution()))
165-
print(" Python %s" % platform.python_version())
166-
print(" PYTHONPATH=%s" % os.environ["PYTHONPATH"])
162+
print(f" Python {platform.python_version()}")
163+
print(f" PYTHONPATH={os.environ['PYTHONPATH']}")
167164
print()
168165

169166

@@ -222,13 +219,9 @@ def run_test(self, test, fmt, i):
222219
res_msg = f" {res} {took:.3f}s"
223220
self.print_(res_msg)
224221

225-
if (
226-
stdout
227-
and not stdout.endswith("PASSED\n")
228-
and not (stdout.endswith("NO RESULT\n"))
229-
):
222+
if stdout and not stdout.endswith(("PASSED\n", "NO RESULT\n")):
230223
print()
231-
print("\n".join(" %s" % line for line in stdout.splitlines()))
224+
print("\n".join(f" {line}" for line in stdout.splitlines()))
232225
elif not self.isatty:
233226
print()
234227

0 commit comments

Comments
 (0)