8000 gh-104683: Argument clinic: Minor readability improvements for `Desti… · python/cpython@7ce3ea4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ce3ea4

Browse files
authored
gh-104683: Argument clinic: Minor readability improvements for Destination.__init__ (#106652)
1 parent de82732 commit 7ce3ea4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Tools/clinic/clinic.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,14 +1959,19 @@ def __init__(self, name, type, clinic, *args):
19591959
self.name = name
19601960
self.type = type
19611961
self.clinic = clinic
1962+
self.buffers = BufferSeries()
1963+
19621964
valid_types = ('buffer', 'file', 'suppress')
19631965
if type not in valid_types:
1964-
fail("Invalid destination type " + repr(type) + " for " + name + " , must be " + ', '.join(valid_types))
1966+
fail(
1967+
f"Invalid destination type {type!r} for {name}, "
1968+
f"must be {', '.join(valid_types)}"
1969+
)
19651970
extra_arguments = 1 if 8000 type == "file" else 0
19661971
if len(args) < extra_arguments:
1967-
fail("Not enough arguments for destination " + name + " new " + type)
1972+
fail(f"Not enough arguments for destination {name} new {type}")
19681973
if len(args) > extra_arguments:
1969-
fail("Too many arguments for destination " + name + " new " + type)
1974+
fail(f"Too many arguments for destination {name} new {type}")
19701975
if type =='file':
19711976
d = {}
19721977
filename = clinic.filename
@@ -1979,8 +1984,6 @@ def __init__(self, name, type, clinic, *args):
19791984
d['basename_root'], d['basename_extension'] = os.path.splitext(filename)
19801985
self.filename = args[0].format_map(d)
19811986

1982-
self.buffers = BufferSeries()
1983-
19841987
def __repr__(self):
19851988
if self.type == 'file':
19861989
file_repr = " " + repr(self.filename)

0 commit comments

Comments
 (0)
0