diff options
| author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-07-11 23:08:28 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-11 23:08:28 (GMT) |
| commit | 7ce3ea4906986c2bab784c878d31c57b14ee1945 (patch) | |
| tree | 3c61764dc3a0a7c996c5f76465a4bda4a9ba5128 | |
| parent | de827322ca47e51d52ff44536a7c3fd44648383a (diff) | |
| download | cpython-7ce3ea4906986c2bab784c878d31c57b14ee1945.zip cpython-7ce3ea4906986c2bab784c878d31c57b14ee1945.tar.gz cpython-7ce3ea4906986c2bab784c878d31c57b14ee1945.tar.bz2 | |
gh-104683: Argument clinic: Minor readability improvements for `Destination.__init__` (#106652)
| -rwxr-xr-x | Tools/clinic/clinic.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 12ab633..a0cf50b 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -1959,14 +1959,19 @@ class Destination: self.name = name self.type = type self.clinic = clinic + self.buffers = BufferSeries() + valid_types = ('buffer', 'file', 'suppress') if type not in valid_types: - fail("Invalid destination type " + repr(type) + " for " + name + " , must be " + ', '.join(valid_types)) + fail( + f"Invalid destination type {type!r} for {name}, " + f"must be {', '.join(valid_types)}" + ) extra_arguments = 1 if type == "file" else 0 if len(args) < extra_arguments: - fail("Not enough arguments for destination " + name + " new " + type) + fail(f"Not enough arguments for destination {name} new {type}") if len(args) > extra_arguments: - fail("Too many arguments for destination " + name + " new " + type) + fail(f"Too many arguments for destination {name} new {type}") if type =='file': d = {} filename = clinic.filename @@ -1979,8 +1984,6 @@ class Destination: d['basename_root'], d['basename_extension'] = os.path.splitext(filename) self.filename = args[0].format_map(d) - self.buffers = BufferSeries() - def __repr__(self): if self.type == 'file': file_repr = " " + repr(self.filename) |
