diff --git a/Orange/widgets/data/oweditdomain.py b/Orange/widgets/data/oweditdomain.py index 9f4463a760e..3f20d32c8d6 100644 --- a/Orange/widgets/data/oweditdomain.py +++ b/Orange/widgets/data/oweditdomain.py @@ -378,8 +378,8 @@ def reconstruct(tname, args): """ try: constructor = globals()[tname] - except KeyError: - raise NameError(tname) + except KeyError as exc: + raise NameError(tname) from exc return constructor(*args) @@ -1327,7 +1327,7 @@ def set_data_categorical(self, var, values, transform=()): SourceNameRole: ci } else: - assert False, "invalid mapping: {!r}".format(tr.mapping) + assert False, f"invalid mapping: {tr.mapping}" items.append(item) elif var is not None: items = [ @@ -1457,8 +1457,7 @@ def _remove_category(self): # new level -> remove it model.removeRow(index.row()) else: - assert False, "invalid state '{}' for {}" \ - .format(state, index.row()) + assert False, f"invalid state '{state}' for {index.row()}" def _add_category(self): """ @@ -1633,8 +1632,7 @@ def initStyleOption(self, option, index): text = var.name for tr in transform: if isinstance(tr, Rename): - text = ("{} \N{RIGHTWARDS ARROW} {}" - .format(var.name, tr.name)) + text = f"{var.name} \N{RIGHTWARDS ARROW} {tr.name}" for tr in transform: if isinstance(tr, ReinterpretTransformTypes): text += f" (reinterpreted as " \ @@ -2075,21 +2073,21 @@ def __init__(self): gui.rubber(self.buttonsArea) bbox = gui.hBox(self.buttonsArea) - breset_all = gui.button( + gui.button( bbox, self, "Reset All", objectName="button-reset-all", toolTip="Reset all variables to their input state.", autoDefault=False, callback=self.reset_all ) - breset = gui.button( + gui.button( bbox, self, "Reset Selected", objectName="button-reset", toolTip="Rest selected variable to its input state.", autoDefault=False, callback=self.reset_selected ) - bapply = gui.button( + gui.button( bbox, self, "Apply", objectName="button-apply", toolTip="Apply changes and commit data on output.", @@ -2282,7 +2280,7 @@ def _restore_transform(self, var): tr.append(reconstruct(*t)) except (NameError, TypeError) as err: warnings.warn( - "Failed to restore transform: {}, {!r}".format(t, err), + f"Failed to restore transform: {t}, {err}", UserWarning, stacklevel=2 ) if tr: @@ -2401,7 +2399,7 @@ def send_report(self): parts.append(report_transform(vector.vtype, trs)) if parts: html = ("