Skip to content

Commit 5b8cbf1

Browse files
committed
Upgrade Python syntax with pyupgrade --py37-plus
1 parent df4ca02 commit 5b8cbf1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/apipkg/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(self, name, importspec, implprefix=None, attr=None):
155155
setattr(self, name, val)
156156
for name, importspec in importspec.items():
157157
if isinstance(importspec, dict):
158-
subname = "{}.{}".format(self.__name__, name)
158+
subname = f"{self.__name__}.{name}"
159159
apimod = ApiModule(subname, importspec, implprefix)
160160
sys.modules[subname] = apimod
161161
setattr(self, name, apimod)
@@ -167,7 +167,7 @@ def __init__(self, name, importspec, implprefix=None, attr=None):
167167
modpath = implprefix + modpath
168168

169169
if not attrname:
170-
subname = "{}.{}".format(self.__name__, name)
170+
subname = f"{self.__name__}.{name}"
171171
apimod = AliasModule(subname, modpath)
172172
sys.modules[subname] = apimod
173173
if "." not in name:
@@ -183,7 +183,7 @@ def __repr__(self):
183183
repr_list.append("from " + repr(self.__file__))
184184
if repr_list:
185185
return "<ApiModule {!r} {}>".format(self.__name__, " ".join(repr_list))
186-
return "<ApiModule {!r}>".format(self.__name__)
186+
return f"<ApiModule {self.__name__!r}>"
187187

188188
@_synchronized
189189
def __makeattr(self, name, isgetattr=False):
@@ -210,7 +210,7 @@ def __makeattr(self, name, isgetattr=False):
210210
# * Only call __getattribute__ if there is a possibility something has set
211211
# the attribute we're looking for since __getattr__ was called
212212
if threading is not None and isgetattr:
213-
return super(ApiModule, self).__getattribute__(name)
213+
return super().__getattribute__(name)
214214
raise AttributeError(name)
215215
else:
216216
result = importobj(modpath, attrname)
@@ -252,7 +252,7 @@ def getmod():
252252
return mod[0]
253253

254254
x = modpath + ("." + attrname if attrname else "")
255-
repr_result = "<AliasModule {!r} for {!r}>".format(modname, x)
255+
repr_result = f"<AliasModule {modname!r} for {x!r}>"
256256

257257
class AliasModule(ModuleType):
258258
def __repr__(self):

test_apipkg.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ def parsenamespace(spec):
254254
continue
255255
parts = [x.strip() for x in line.split()]
256256
if len(parts) != 2:
257-
raise ValueError("Wrong format: {!r}".format(line))
257+
raise ValueError(f"Wrong format: {line!r}")
258258
apiname, spec = parts
259259
if not spec.startswith("__"):
260-
raise ValueError("{!r} does not start with __".format(spec))
260+
raise ValueError(f"{spec!r} does not start with __")
261261
apinames = apiname.split(".")
262262
cur = ns
263263
for name in apinames[:-1]:
@@ -493,7 +493,7 @@ def init():
493493

494494
class TestThread(threading.Thread):
495495
def __init__(self, event_start):
496-
super(TestThread, self).__init__()
496+
super().__init__()
497497
self.event_start = event_start
498498
self.lenl = None
499499

@@ -544,7 +544,7 @@ def test_attribute_race(tmpdir, monkeypatch):
544544

545545
class TestThread(threading.Thread):
546546
def __init__(self, event_start):
547-
super(TestThread, self).__init__()
547+
super().__init__()
548548
self.event_start = event_start
549549
self.attr = None
550550

@@ -591,7 +591,7 @@ def test_import_race(tmpdir, monkeypatch):
591591

592592
class TestThread(threading.Thread):
593593
def __init__(self):
594-
super(TestThread, self).__init__()
594+
super().__init__()
595595
self.importrace = None
596596

597597
def run(self):

0 commit comments

Comments
 (0)