Skip to content

Commit 792157d

Browse files
simonwclaude
andcommitted
Fix type errors in tests and plugins
- Add type: ignore for monkey-patching Database.__init__ in conftest - Fix CLI test to pass string "2" instead of integer to Click invoke - Add type: ignore for optional sqlean import - Fix add_geometry_column test to use "XY" instead of integer 2 - Add type: ignore for click.Context as context manager - Add type: ignore for enable_fts test that intentionally omits argument - Add type: ignore for sys._called_from_test dynamic attribute - Fix rows_from_file test type error for intentional wrong argument - Handle None from pm.get_hookcallers in plugins.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent a0000f2 commit 792157d

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

sqlite_utils/plugins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ def get_plugins():
1414
plugins = []
1515
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
1616
for plugin in pm.get_plugins():
17+
hookcallers = pm.get_hookcallers(plugin) or []
1718
plugin_info = {
1819
"name": plugin.__name__,
19-
"hooks": [h.name for h in pm.get_hookcallers(plugin)],
20+
"hooks": [h.name for h in hookcallers],
2021
}
2122
distinfo = plugin_to_distinfo.get(plugin)
2223
if distinfo:

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def pytest_configure(config):
1212
import sys
1313

14-
sys._called_from_test = True
14+
sys._called_from_test = True # type: ignore[attr-defined]
1515

1616

1717
@pytest.fixture(autouse=True)
@@ -24,9 +24,9 @@ def tracking_init(self, *args, **kwargs):
2424
original_init(self, *args, **kwargs)
2525
databases.append(self)
2626

27-
Database.__init__ = tracking_init
27+
Database.__init__ = tracking_init # type: ignore[method-assign]
2828
yield
29-
Database.__init__ = original_init
29+
Database.__init__ = original_init # type: ignore[method-assign]
3030
for db in databases:
3131
try:
3232
db.close()

tests/test_cli_convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def test_convert_where(test_db_and_path):
535535
"id = :id",
536536
"-p",
537537
"id",
538-
2,
538+
"2",
539539
],
540540
)
541541
assert result.exit_code == 0, result.output
@@ -564,7 +564,7 @@ def test_convert_where_multi(fresh_db_and_path):
564564
"id = :id",
565565
"-p",
566566
"id",
567-
2,
567+
"2",
568568
"--multi",
569569
],
570570
)

tests/test_cli_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def test_memory_return_db(tmpdir):
331331
with open(path, "w") as f:
332332
f.write("id,name\n1,Cleo")
333333

334-
with click.Context(cli) as ctx:
334+
with click.Context(cli) as ctx: # type: ignore[attr-defined]
335335
db = ctx.invoke(cli.commands["memory"], paths=(path,), return_db=True)
336336

337337
assert db.table_names() == ["dogs"]

tests/test_fts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def test_enable_fts_error_message_on_views():
424424
db = Database(memory=True)
425425
db.create_view("hello", "select 1 + 1")
426426
with pytest.raises(NotImplementedError) as e:
427-
db["hello"].enable_fts()
427+
db["hello"].enable_fts() # type: ignore[call-arg]
428428
assert e.value.args[0] == "enable_fts() is supported on tables but not on views"
429429

430430

tests/test_gis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from sqlite_utils.utils import find_spatialite, sqlite3
88

99
try:
10-
import sqlean
10+
import sqlean # type: ignore[import-not-found]
1111
except ImportError:
1212
sqlean = None
1313

@@ -50,7 +50,7 @@ def test_add_geometry_column():
5050
column_name="geometry",
5151
geometry_type="Point",
5252
srid=4326,
53-
coord_dimension=2,
53+
coord_dimension="XY",
5454
)
5555

5656
assert db["geometry_columns"].get(["locations", "geometry"]) == {

tests/test_rows_from_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_rows_from_file_extra_fields_strategies(ignore_extras, extras_key, expec
4848

4949
def test_rows_from_file_error_on_string_io():
5050
with pytest.raises(TypeError) as ex:
51-
rows_from_file(StringIO("id,name\r\n1,Cleo"))
51+
rows_from_file(StringIO("id,name\r\n1,Cleo")) # type: ignore[arg-type]
5252
assert ex.value.args == (
5353
"rows_from_file() requires a file-like object that supports peek(), such as io.BytesIO",
5454
)

0 commit comments

Comments
 (0)