Skip to content

Commit c30afd8

Browse files
committed
Silence some mypy warnings
1 parent 333e654 commit c30afd8

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ warn_return_any = True
1010
show_error_codes = True
1111
warn_unused_ignores = True
1212
ignore_missing_imports = True
13+
plugins = pydantic.mypy

sqlsynthgen/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_db_engine(
7070

7171
@event.listens_for(event_engine, "connect", insert=True)
7272
def connect(dbapi_connection: Any, _: Any) -> None:
73-
set_search_path(dbapi_connection, schema_name) # type: ignore
73+
set_search_path(dbapi_connection, schema_name)
7474

7575
return engine
7676

tests/test_remove.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def test_remove_db_data(
3131
@patch("sqlsynthgen.remove.get_settings")
3232
def test_remove_db_data_raises(self, mock_get: MagicMock) -> None:
3333
"""Check that remove_db_data raises if dst DSN is missing."""
34-
mock_get.return_value = Settings(dst_dsn=None, _env_file=None)
34+
mock_get.return_value = Settings(
35+
dst_dsn=None,
36+
# The mypy ignore can be removed once we upgrade to pydantic 2.
37+
_env_file=None, # type: ignore[call-arg]
38+
)
3539
with self.assertRaises(AssertionError) as context_manager:
3640
remove_db_data(example_orm, remove_ssg)
3741
self.assertEqual(
@@ -56,7 +60,11 @@ def test_remove_db_vocab(
5660
@patch("sqlsynthgen.remove.get_settings")
5761
def test_remove_db_vocab_raises(self, mock_get: MagicMock) -> None:
5862
"""Check that remove_db_vocab raises if dst DSN is missing."""
59-
mock_get.return_value = Settings(dst_dsn=None, _env_file=None)
63+
mock_get.return_value = Settings(
64+
dst_dsn=None,
65+
# The mypy ignore can be removed once we upgrade to pydantic 2.
66+
_env_file=None, # type: ignore[call-arg]
67+
)
6068
with self.assertRaises(AssertionError) as context_manager:
6169
remove_db_vocab(example_orm, remove_ssg)
6270
self.assertEqual(
@@ -75,7 +83,11 @@ def test_remove_tables(self, mock_engine: MagicMock, _: MagicMock) -> None:
7583
@patch("sqlsynthgen.remove.get_settings")
7684
def test_remove_db_tables_raises(self, mock_get: MagicMock) -> None:
7785
"""Check that remove_db_tables raises if dst DSN is missing."""
78-
mock_get.return_value = Settings(dst_dsn=None, _env_file=None)
86+
mock_get.return_value = Settings(
87+
dst_dsn=None,
88+
# The mypy ignore can be removed once we upgrade to pydantic 2.
89+
_env_file=None, # type: ignore[call-arg]
90+
)
7991
with self.assertRaises(AssertionError) as context_manager:
8092
remove_db_tables(example_orm)
8193
self.assertEqual(

tests/test_settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def test_minimal_settings(self) -> None:
1212
"""Test the minimal settings."""
1313
settings = Settings(
1414
# To stop any local .env files influencing the test
15-
_env_file=None,
15+
# The mypy ignore can be removed once we upgrade to pydantic 2.
16+
_env_file=None, # type: ignore[call-arg]
1617
)
1718
self.assertIsNone(settings.src_dsn)
1819
self.assertIsNone(settings.src_schema)
@@ -28,7 +29,8 @@ def test_maximal_settings(self) -> None:
2829
dst_dsn="postgresql://user:password@host:port/db_name?sslmode=require",
2930
dst_schema="src_schema",
3031
# To stop any local .env files influencing the test
31-
_env_file=None,
32+
# The mypy ignore can be removed once we upgrade to pydantic 2.
33+
_env_file=None, # type: ignore[call-arg]
3234
)
3335

3436
def test_validation(self) -> None:

tests/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def get_test_settings() -> settings.Settings:
2121
src_dsn="postgresql://suser:spassword@shost:5432/sdbname",
2222
dst_dsn="postgresql://duser:dpassword@dhost:5432/ddbname",
2323
# To stop any local .env files influencing the test
24-
_env_file=None,
24+
# The mypy ignore can be removed once we upgrade to pydantic 2.
25+
_env_file=None, # type: ignore[call-arg]
2526
)
2627

2728

0 commit comments

Comments
 (0)