]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104683: Argument clinic: Minor readability improvements for `Destination.__init__...
authorAlex Waygood <Alex.Waygood@Gmail.com>
Tue, 11 Jul 2023 23:08:28 +0000 (00:08 +0100)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2023 23:08:28 +0000 (23:08 +0000)
Tools/clinic/clinic.py

index 12ab633388485eeff5969191bca4a0cf8e882e48..a0cf50b29c978db3eb0f1f25b6c7dc8d52f7bcc1 100755 (executable)
@@ -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)