mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-12 03:24:23 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
a0000f2b26
commit
792157d120
7 changed files with 12 additions and 11 deletions
|
|
@ -14,9 +14,10 @@ def get_plugins():
|
|||
plugins = []
|
||||
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
|
||||
for plugin in pm.get_plugins():
|
||||
hookcallers = pm.get_hookcallers(plugin) or []
|
||||
plugin_info = {
|
||||
"name": plugin.__name__,
|
||||
"hooks": [h.name for h in pm.get_hookcallers(plugin)],
|
||||
"hooks": [h.name for h in hookcallers],
|
||||
}
|
||||
distinfo = plugin_to_distinfo.get(plugin)
|
||||
if distinfo:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ create table Gosh2 (c1 text, c2 text, c3 text);
|
|||
def pytest_configure(config):
|
||||
import sys
|
||||
|
||||
sys._called_from_test = True
|
||||
sys._called_from_test = True # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
@ -24,9 +24,9 @@ def close_all_databases():
|
|||
original_init(self, *args, **kwargs)
|
||||
databases.append(self)
|
||||
|
||||
Database.__init__ = tracking_init
|
||||
Database.__init__ = tracking_init # type: ignore[method-assign]
|
||||
yield
|
||||
Database.__init__ = original_init
|
||||
Database.__init__ = original_init # type: ignore[method-assign]
|
||||
for db in databases:
|
||||
try:
|
||||
db.close()
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ def test_convert_where(test_db_and_path):
|
|||
"id = :id",
|
||||
"-p",
|
||||
"id",
|
||||
2,
|
||||
"2",
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
|
|
@ -564,7 +564,7 @@ def test_convert_where_multi(fresh_db_and_path):
|
|||
"id = :id",
|
||||
"-p",
|
||||
"id",
|
||||
2,
|
||||
"2",
|
||||
"--multi",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ def test_memory_return_db(tmpdir):
|
|||
with open(path, "w") as f:
|
||||
f.write("id,name\n1,Cleo")
|
||||
|
||||
with click.Context(cli) as ctx:
|
||||
with click.Context(cli) as ctx: # type: ignore[attr-defined]
|
||||
db = ctx.invoke(cli.commands["memory"], paths=(path,), return_db=True)
|
||||
|
||||
assert db.table_names() == ["dogs"]
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ def test_enable_fts_error_message_on_views():
|
|||
db = Database(memory=True)
|
||||
db.create_view("hello", "select 1 + 1")
|
||||
with pytest.raises(NotImplementedError) as e:
|
||||
db["hello"].enable_fts()
|
||||
db["hello"].enable_fts() # type: ignore[call-arg]
|
||||
assert e.value.args[0] == "enable_fts() is supported on tables but not on views"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from sqlite_utils.db import Database
|
|||
from sqlite_utils.utils import find_spatialite, sqlite3
|
||||
|
||||
try:
|
||||
import sqlean
|
||||
import sqlean # type: ignore[import-not-found]
|
||||
except ImportError:
|
||||
sqlean = None
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ def test_add_geometry_column():
|
|||
column_name="geometry",
|
||||
geometry_type="Point",
|
||||
srid=4326,
|
||||
coord_dimension=2,
|
||||
coord_dimension="XY",
|
||||
)
|
||||
|
||||
assert db["geometry_columns"].get(["locations", "geometry"]) == {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ def test_rows_from_file_extra_fields_strategies(ignore_extras, extras_key, expec
|
|||
|
||||
def test_rows_from_file_error_on_string_io():
|
||||
with pytest.raises(TypeError) as ex:
|
||||
rows_from_file(StringIO("id,name\r\n1,Cleo"))
|
||||
rows_from_file(StringIO("id,name\r\n1,Cleo")) # type: ignore[arg-type]
|
||||
assert ex.value.args == (
|
||||
"rows_from_file() requires a file-like object that supports peek(), such as io.BytesIO",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue