diff --git a/src/textual/_markup_playground.py b/src/textual/_markup_playground.py index f45fcabcba..77724e454f 100644 --- a/src/textual/_markup_playground.py +++ b/src/textual/_markup_playground.py @@ -128,7 +128,7 @@ def on_variables_change(self, event: TextArea.Changed) -> None: variables_text_area = self.query_one("#variables", TextArea) try: variables = json.loads(variables_text_area.text) - except Exception as error: + except Exception: variables_text_area.add_class("-bad-json") self.variables = {} else: diff --git a/src/textual/drivers/linux_inline_driver.py b/src/textual/drivers/linux_inline_driver.py index 14aa61fba0..c150c64430 100644 --- a/src/textual/drivers/linux_inline_driver.py +++ b/src/textual/drivers/linux_inline_driver.py @@ -298,7 +298,7 @@ def disable_input(self) -> None: except termios.error: pass - except Exception as error: + except Exception: # TODO: log this pass diff --git a/src/textual/drivers/windows_driver.py b/src/textual/drivers/windows_driver.py index 76fd965652..aa98f53ce3 100644 --- a/src/textual/drivers/windows_driver.py +++ b/src/textual/drivers/windows_driver.py @@ -115,7 +115,7 @@ def disable_input(self) -> None: self._event_thread.join() self._event_thread = None self.exit_event.clear() - except Exception as error: + except Exception: # TODO: log this pass diff --git a/src/textual/validation.py b/src/textual/validation.py index 9ce79a9b83..2ab69423e8 100644 --- a/src/textual/validation.py +++ b/src/textual/validation.py @@ -361,7 +361,7 @@ def validate(self, value: str) -> ValidationResult: # We know it's a number, but is that number an integer? try: - int_value = int(value) + int(value) except ValueError: return ValidationResult.failure([Integer.NotAnInteger(self, value)]) return self.success() diff --git a/src/textual/widgets/_log.py b/src/textual/widgets/_log.py index bcf9c87132..292a634745 100644 --- a/src/textual/widgets/_log.py +++ b/src/textual/widgets/_log.py @@ -173,7 +173,6 @@ def write( Returns: The `Log` instance. """ - is_vertical_scroll_end = self.is_vertical_scroll_end if data: if not self._lines: self._lines.append("") diff --git a/tests/css/test_inheritance.py b/tests/css/test_inheritance.py index 2dd6f25a4e..64ad5f9e85 100644 --- a/tests/css/test_inheritance.py +++ b/tests/css/test_inheritance.py @@ -33,7 +33,7 @@ def compose(self) -> ComposeResult: app = InheritanceApp() async with app.run_test(): - widget1 = app.query_one("#widget1", Widget1) + app.query_one("#widget1", Widget1) widget2 = app.query_one("#widget2", Widget2) assert widget2.styles.background == Color.parse("green") diff --git a/tests/css/test_parse.py b/tests/css/test_parse.py index bb18c44d5a..23dd9636e2 100644 --- a/tests/css/test_parse.py +++ b/tests/css/test_parse.py @@ -1106,7 +1106,7 @@ def test_various_duration_formats(self, duration, parsed_duration): } def test_no_delay_specified(self): - css = f"#some-widget {{ transition: offset-x 1 in_out_cubic; }}" + css = "#some-widget { transition: offset-x 1 in_out_cubic; }" stylesheet = Stylesheet() stylesheet.add_source(css) diff --git a/tests/snapshot_tests/snapshot_apps/data_table_add_column.py b/tests/snapshot_tests/snapshot_apps/data_table_add_column.py index d80af7eebf..a792a195a4 100644 --- a/tests/snapshot_tests/snapshot_apps/data_table_add_column.py +++ b/tests/snapshot_tests/snapshot_apps/data_table_add_column.py @@ -1,6 +1,6 @@ from textual.app import App, ComposeResult from textual.binding import Binding -from textual.widgets import DataTable, Footer +from textual.widgets import DataTable MOVIES = [ "Severance", diff --git a/tests/snapshot_tests/snapshot_apps/directory_tree_reload.py b/tests/snapshot_tests/snapshot_apps/directory_tree_reload.py index f8c0dee21f..1603637952 100644 --- a/tests/snapshot_tests/snapshot_apps/directory_tree_reload.py +++ b/tests/snapshot_tests/snapshot_apps/directory_tree_reload.py @@ -1,6 +1,6 @@ from pathlib import Path -from textual.app import App, ComposeResult +from textual.app import App from textual.widgets import DirectoryTree diff --git a/tests/snapshot_tests/snapshot_apps/log_write.py b/tests/snapshot_tests/snapshot_apps/log_write.py index dbca071221..6090bd1f76 100644 --- a/tests/snapshot_tests/snapshot_apps/log_write.py +++ b/tests/snapshot_tests/snapshot_apps/log_write.py @@ -1,6 +1,5 @@ from textual.app import App, ComposeResult from textual.widgets import Log -from textual.containers import Horizontal class LogApp(App): diff --git a/tests/snapshot_tests/snapshot_apps/mount_style_fix.py b/tests/snapshot_tests/snapshot_apps/mount_style_fix.py index 038ce75ba6..8aafe10f6c 100644 --- a/tests/snapshot_tests/snapshot_apps/mount_style_fix.py +++ b/tests/snapshot_tests/snapshot_apps/mount_style_fix.py @@ -1,4 +1,3 @@ -from textual import __version__ from textual.app import App, ComposeResult from textual.widgets import Static diff --git a/tests/snapshot_tests/snapshot_apps/scroll_page.py b/tests/snapshot_tests/snapshot_apps/scroll_page.py index 33243fef5c..29280a0249 100644 --- a/tests/snapshot_tests/snapshot_apps/scroll_page.py +++ b/tests/snapshot_tests/snapshot_apps/scroll_page.py @@ -1,4 +1,3 @@ -import os from textual.app import App from textual.widgets import RichLog diff --git a/tests/snapshot_tests/snapshot_apps/text_selection.py b/tests/snapshot_tests/snapshot_apps/text_selection.py index d76ce89e9b..5b012a74f0 100644 --- a/tests/snapshot_tests/snapshot_apps/text_selection.py +++ b/tests/snapshot_tests/snapshot_apps/text_selection.py @@ -3,7 +3,6 @@ from textual.widgets import Label from textual.containers import VerticalGroup -from textual.content import Content TEXT = """I must not fear. Fear is the mind-killer. diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 4eac45ec03..01a801a062 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -10,7 +10,6 @@ from tests.snapshot_tests.language_snippets import SNIPPETS from textual import events from textual._on import on -from textual import work from textual.app import App, ComposeResult from textual.binding import Binding from textual.color import Color, ColorParseError @@ -936,7 +935,7 @@ def compose(self) -> ComposeResult: ) yield rich_log width_marker = Label( - f"this label is width 50 (same as min_width)", id="width-marker" + "this label is width 50 (same as min_width)", id="width-marker" ) yield width_marker @@ -3796,7 +3795,7 @@ def compose(self) -> ComposeResult: Create the user interface """ - self.last_updated = Label(f"Last Updated: NOW", id="last_updated") + self.last_updated = Label("Last Updated: NOW", id="last_updated") yield Header() yield Vertical( diff --git a/tests/test_data_table.py b/tests/test_data_table.py index 6750c5ddbc..5177c18eb7 100644 --- a/tests/test_data_table.py +++ b/tests/test_data_table.py @@ -497,7 +497,7 @@ async def test_get_cell_coordinate_invalid_row_key(): table.add_row("TargetValue", key="R1") with pytest.raises(CellDoesNotExist): - coordinate = table.get_cell_coordinate("INVALID_ROW", "C1") + table.get_cell_coordinate("INVALID_ROW", "C1") async def test_get_cell_coordinate_invalid_column_key(): @@ -508,7 +508,7 @@ async def test_get_cell_coordinate_invalid_column_key(): table.add_row("TargetValue", key="R1") with pytest.raises(CellDoesNotExist): - coordinate = table.get_cell_coordinate("R1", "INVALID_COLUMN") + table.get_cell_coordinate("R1", "INVALID_COLUMN") async def test_get_cell_at_returns_value_at_cell(): @@ -607,7 +607,7 @@ async def test_get_row_index_invalid_row_key(): table.add_row("TargetValue", key="R1") with pytest.raises(RowDoesNotExist): - index = table.get_row_index("InvalidRow") + table.get_row_index("InvalidRow") async def test_get_column(): @@ -680,7 +680,7 @@ async def test_get_column_index_invalid_column_key(): table.add_row("TargetValue1", "TargetValue2", "TargetValue3", key="R1") with pytest.raises(ColumnDoesNotExist): - index = table.get_column_index("InvalidCol") + table.get_column_index("InvalidCol") async def test_update_cell_cell_exists(): @@ -1397,7 +1397,7 @@ async def test_add_row_expands_column_widths(): async def test_cell_padding_updates_virtual_size(): app = DataTableApp() - async with app.run_test() as pilot: + async with app.run_test(): table = app.query_one(DataTable) table.add_column("First") table.add_column("Second", width=10) diff --git a/tests/test_query.py b/tests/test_query.py index 5fde811450..f914b1335a 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -331,7 +331,7 @@ def compose(self): yield MyWidget() app = MyApp() - async with app.run_test() as pilot: + async with app.run_test(): app.query(MyWidget).refresh(repaint=args[0], layout=args[1]) assert refreshes[-1] == args diff --git a/tests/test_reactive.py b/tests/test_reactive.py index 6663f7d79f..324be44ec2 100644 --- a/tests/test_reactive.py +++ b/tests/test_reactive.py @@ -297,7 +297,7 @@ def compose(self) -> ComposeResult: yield BrokenWidget() app = PrematureApp() - async with app.run_test() as pilot: + async with app.run_test(): assert watcher_called app.exit() diff --git a/tests/test_widget.py b/tests/test_widget.py index 1ce6dfebca..bd8f3b1aed 100644 --- a/tests/test_widget.py +++ b/tests/test_widget.py @@ -626,10 +626,9 @@ def test_lazy_loading() -> None: """ with pytest.raises(ImportError): - from textual.widgets import Foo # nopycln: import + pass # nopycln: import from textual import widgets - from textual.widgets import Label assert not hasattr(widgets, "foo") assert not hasattr(widgets, "bar") diff --git a/tests/text_area/test_history.py b/tests/text_area/test_history.py index 1d0c7a0b0b..d605b57b83 100644 --- a/tests/text_area/test_history.py +++ b/tests/text_area/test_history.py @@ -58,7 +58,7 @@ async def text_area(pilot): async def test_simple_undo_redo(): app = TextAreaApp() - async with app.run_test() as pilot: + async with app.run_test(): text_area = app.text_area text_area.insert("123", (0, 0)) @@ -188,7 +188,7 @@ async def test_undo_checkpoint_character_limit_reached(): async def test_redo_with_no_undo_is_noop(): app = TextAreaApp() - async with app.run_test() as pilot: + async with app.run_test(): text_area = app.text_area text_area.text = SIMPLE_TEXT text_area.redo() @@ -197,7 +197,7 @@ async def test_redo_with_no_undo_is_noop(): async def test_undo_with_empty_undo_stack_is_noop(): app = TextAreaApp() - async with app.run_test() as pilot: + async with app.run_test(): text_area = app.text_area text_area.text = SIMPLE_TEXT text_area.undo()