Browse code

prefer f-strings over string.format

Bas Nijholt authored on 10/05/2019 00:33:55
Showing 3 changed files
... ...
@@ -390,7 +390,7 @@ class IntegratorLearner(BaseLearner):
390 390
 
391 391
     def tell(self, point, value):
392 392
         if point not in self.x_mapping:
393
-            raise ValueError("Point {} doesn't belong to any interval".format(point))
393
+            raise ValueError(f"Point {point} doesn't belong to any interval")
394 394
         self.done_points[point] = value
395 395
         self.pending_points.discard(point)
396 396
 
... ...
@@ -751,4 +751,4 @@ def _get_ncores(ex):
751 751
         ex.bootup()  # wait until all workers are up and running
752 752
         return ex._pool.size  # not public API!
753 753
     else:
754
-        raise TypeError("Cannot get number of cores for {}".format(ex.__class__))
754
+        raise TypeError(f"Cannot get number of cores for {ex.__class__}")
... ...
@@ -75,7 +75,7 @@ def generate_random_parametrization(f):
75 75
     _, *params = inspect.signature(f).parameters.items()
76 76
     if any(not callable(v.annotation) for (p, v) in params):
77 77
         raise TypeError(
78
-            "All parameters to {} must be annotated with functions.".format(f.__name__)
78
+            f"All parameters to {f.__name__} must be annotated with functions."
79 79
         )
80 80
     realization = {p: v.annotation() for (p, v) in params}
81 81
     return ft.partial(f, **realization)