Skip to content

Commit 683d9ca

Browse files
simonwclaude
andcommitted
Fix mypy type errors
- Add type: ignore comments for runtime-valid patterns mypy can't verify - Fix new_column_types annotation to Dict[str, Set[type]] - Add type: ignore for Default sentinel values passed to create_table 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9b1daa3 commit 683d9ca

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

sqlite_utils/db.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,18 +1819,18 @@ def create(
18191819
self.name,
18201820
columns,
18211821
pk=pk,
1822-
foreign_keys=foreign_keys,
1823-
column_order=column_order,
1824-
not_null=not_null,
1825-
defaults=defaults,
1826-
hash_id=hash_id,
1827-
hash_id_columns=hash_id_columns,
1828-
extracts=extracts,
1822+
foreign_keys=foreign_keys, # type: ignore[arg-type]
1823+
column_order=column_order, # type: ignore[arg-type]
1824+
not_null=not_null, # type: ignore[arg-type]
1825+
defaults=defaults, # type: ignore[arg-type]
1826+
hash_id=hash_id, # type: ignore[arg-type]
1827+
hash_id_columns=hash_id_columns, # type: ignore[arg-type]
1828+
extracts=extracts, # type: ignore[arg-type]
18291829
if_not_exists=if_not_exists,
18301830
replace=replace,
18311831
ignore=ignore,
18321832
transform=transform,
1833-
strict=strict,
1833+
strict=strict, # type: ignore[arg-type]
18341834
)
18351835
return self
18361836

@@ -3053,7 +3053,7 @@ def _convert_multi(
30533053
):
30543054
# First we execute the function
30553055
pk_to_values = {}
3056-
new_column_types = {}
3056+
new_column_types: Dict[str, Set[type]] = {}
30573057
pks = [column.name for column in self.columns if column.is_pk]
30583058
if not pks:
30593059
pks = ["rowid"]
@@ -3559,7 +3559,7 @@ def insert_all(
35593559
chunk_as_dicts = [dict(zip(column_names, row)) for row in chunk]
35603560
column_types = suggest_column_types(chunk_as_dicts)
35613561
else:
3562-
column_types = suggest_column_types(chunk)
3562+
column_types = suggest_column_types(chunk) # type: ignore[arg-type]
35633563
if extracts:
35643564
for col in extracts:
35653565
if col in column_types:
@@ -3585,9 +3585,9 @@ def insert_all(
35853585
if hash_id:
35863586
all_columns.insert(0, hash_id)
35873587
else:
3588-
all_columns_set = set()
3588+
all_columns_set: Set[str] = set()
35893589
for record in chunk:
3590-
all_columns_set.update(record.keys())
3590+
all_columns_set.update(record.keys()) # type: ignore[union-attr]
35913591
all_columns = list(sorted(all_columns_set))
35923592
if hash_id:
35933593
all_columns.insert(0, hash_id)
@@ -3810,7 +3810,7 @@ def lookup(
38103810
)
38113811
)
38123812
try:
3813-
return rows[0][pk]
3813+
return rows[0][pk] # type: ignore[index]
38143814
except IndexError:
38153815
return self.insert(
38163816
combined_values,

sqlite_utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def get_tests(cls) -> List[str]:
464464

465465
def test_integer(self, value: object) -> bool:
466466
try:
467-
int(value) # type: ignore[arg-type]
467+
int(value) # type: ignore
468468
return True
469469
except (ValueError, TypeError):
470470
return False
@@ -504,7 +504,7 @@ def __init__(self, *args: Iterable[T]) -> None:
504504
self.args = args
505505

506506
def __iter__(self) -> Iterator[T]:
507-
yield from self.args[0]
507+
yield from self.args[0] # type: ignore
508508

509509
def update(self, value: int) -> None:
510510
pass

0 commit comments

Comments
 (0)