From b82b33c28e495f38e252771a53c956d7b31f170b Mon Sep 17 00:00:00 2001 From: Grant Ramsay Date: Sat, 25 Jan 2025 20:32:45 +0000 Subject: [PATCH] formatting changes to suit ruff Signed-off-by: Grant Ramsay --- .pre-commit-config.yaml | 8 ++++---- tests/test_context_manager.py | 6 +++--- tests/test_debug_logging.py | 12 ++++++------ tests/test_properties.py | 24 ++++++++++++------------ tests/test_sqliter.py | 6 +++--- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7500614..0fb768a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,13 +12,13 @@ repos: - id: end-of-file-fixer - repo: https://github.com/renovatebot/pre-commit-hooks - rev: 39.84.0 + rev: 39.133.3 hooks: - id: renovate-config-validator files: ^renovate\.json$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.4 + rev: v0.9.3 hooks: - id: ruff name: "lint with ruff" @@ -26,7 +26,7 @@ repos: name: "format with ruff" - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.14.0" # Use the sha / tag you want to point at + rev: "v1.14.1" # Use the sha / tag you want to point at hooks: - id: mypy name: "run mypy" @@ -35,7 +35,7 @@ repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.5.13 + rev: 0.5.24 hooks: # Update the uv lockfile - id: uv-lock diff --git a/tests/test_context_manager.py b/tests/test_context_manager.py index ff55b73..919330e 100644 --- a/tests/test_context_manager.py +++ b/tests/test_context_manager.py @@ -115,9 +115,9 @@ def test_commit_called_once_in_transaction(self, mocker, tmp_path) -> None: # Assert that the data was committed assert result is not None, "Data was not committed." - assert ( - result[3] == "test" - ), f"Expected slug to be 'test', but got {result[3]}" + assert result[3] == "test", ( + f"Expected slug to be 'test', but got {result[3]}" + ) # Close the new connection new_conn.close() diff --git a/tests/test_debug_logging.py b/tests/test_debug_logging.py index d53a537..a3645cd 100644 --- a/tests/test_debug_logging.py +++ b/tests/test_debug_logging.py @@ -17,16 +17,16 @@ def test_sqliterdb_debug_default(self) -> None: def test_sqliterdb_debug_set_false(self) -> None: """Test that the default value for the debug flag is False.""" db = SqliterDB(":memory:", debug=False) # Set debug argument to False - assert ( - db.debug is False - ), "The debug flag should be False when explicitly passed as False." + assert db.debug is False, ( + "The debug flag should be False when explicitly passed as False." + ) def test_sqliterdb_debug_set_true(self) -> None: """Test that the debug flag can be set to True.""" db = SqliterDB(":memory:", debug=True) # Set debug argument to True - assert ( - db.debug is True - ), "The debug flag should be True when explicitly passed as True." + assert db.debug is True, ( + "The debug flag should be True when explicitly passed as True." + ) def test_debug_sql_output_basic_query( self, db_mock_complex_debug: SqliterDB, caplog diff --git a/tests/test_properties.py b/tests/test_properties.py index 2031f9b..35ce662 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -40,9 +40,9 @@ def test_is_autocommit_property_true(self) -> None: def test_is_autocommit_property_false(self) -> None: """Test 'is_autocommit' prop returns False when auto-commit disabled.""" db = SqliterDB(memory=True, auto_commit=False) - assert ( - db.is_autocommit is False - ), "Expected False for auto-commit disabled" + assert db.is_autocommit is False, ( + "Expected False for auto-commit disabled" + ) def test_is_connected_property_when_connected(self) -> None: """Test the 'is_connected' property when the database is connected.""" @@ -71,9 +71,9 @@ class Meta: # Verify that the table exists while the connection is still open table_names = db.table_names - assert ( - "test_table" in table_names - ), f"Expected 'test_table', got {table_names}" + assert "test_table" in table_names, ( + f"Expected 'test_table', got {table_names}" + ) # Explicitly close the connection afterwards db.close() @@ -94,9 +94,9 @@ class Meta: # Check the table names while the connection is still open table_names = db.table_names - assert ( - "another_table" in table_names - ), f"Expected 'another_table', got {table_names}" + assert "another_table" in table_names, ( + f"Expected 'another_table', got {table_names}" + ) # Close the connection explicitly after the check db.close() @@ -127,9 +127,9 @@ class Meta: # Ensure that accessing table_names does NOT raise an error Since # it's file-based, the table should still exist after reconnecting table_names = db.table_names - assert ( - "test_table" in table_names - ), f"Expected 'test_table', got {table_names}" + assert "test_table" in table_names, ( + f"Expected 'test_table', got {table_names}" + ) def test_table_names_connection_failure(self, mocker) -> None: """Test 'table_names' raises exception if the connection fails.""" diff --git a/tests/test_sqliter.py b/tests/test_sqliter.py index 15c0db1..750faab 100644 --- a/tests/test_sqliter.py +++ b/tests/test_sqliter.py @@ -586,9 +586,9 @@ def test_complex_model_primary_key(self, db_mock) -> None: # Assert that the primary key is the 'id' field and is an INTEGER assert primary_key_column is not None, "Primary key not found" - assert ( - primary_key_column[1] == "pk" - ), f"Expected 'id' as primary key, but got {primary_key_column[1]}" + assert primary_key_column[1] == "pk", ( + f"Expected 'id' as primary key, but got {primary_key_column[1]}" + ) assert primary_key_column[2] == "INTEGER", ( f"Expected 'INTEGER' type for primary key, but got " f"{primary_key_column[2]}"