mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-27 04:14:30 +02:00
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>
This commit is contained in:
parent
9b1daa346a
commit
683d9cac0c
2 changed files with 15 additions and 15 deletions
|
|
@ -1819,18 +1819,18 @@ class Table(Queryable):
|
||||||
self.name,
|
self.name,
|
||||||
columns,
|
columns,
|
||||||
pk=pk,
|
pk=pk,
|
||||||
foreign_keys=foreign_keys,
|
foreign_keys=foreign_keys, # type: ignore[arg-type]
|
||||||
column_order=column_order,
|
column_order=column_order, # type: ignore[arg-type]
|
||||||
not_null=not_null,
|
not_null=not_null, # type: ignore[arg-type]
|
||||||
defaults=defaults,
|
defaults=defaults, # type: ignore[arg-type]
|
||||||
hash_id=hash_id,
|
hash_id=hash_id, # type: ignore[arg-type]
|
||||||
hash_id_columns=hash_id_columns,
|
hash_id_columns=hash_id_columns, # type: ignore[arg-type]
|
||||||
extracts=extracts,
|
extracts=extracts, # type: ignore[arg-type]
|
||||||
if_not_exists=if_not_exists,
|
if_not_exists=if_not_exists,
|
||||||
replace=replace,
|
replace=replace,
|
||||||
ignore=ignore,
|
ignore=ignore,
|
||||||
transform=transform,
|
transform=transform,
|
||||||
strict=strict,
|
strict=strict, # type: ignore[arg-type]
|
||||||
)
|
)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
@ -3053,7 +3053,7 @@ class Table(Queryable):
|
||||||
):
|
):
|
||||||
# First we execute the function
|
# First we execute the function
|
||||||
pk_to_values = {}
|
pk_to_values = {}
|
||||||
new_column_types = {}
|
new_column_types: Dict[str, Set[type]] = {}
|
||||||
pks = [column.name for column in self.columns if column.is_pk]
|
pks = [column.name for column in self.columns if column.is_pk]
|
||||||
if not pks:
|
if not pks:
|
||||||
pks = ["rowid"]
|
pks = ["rowid"]
|
||||||
|
|
@ -3559,7 +3559,7 @@ class Table(Queryable):
|
||||||
chunk_as_dicts = [dict(zip(column_names, row)) for row in chunk]
|
chunk_as_dicts = [dict(zip(column_names, row)) for row in chunk]
|
||||||
column_types = suggest_column_types(chunk_as_dicts)
|
column_types = suggest_column_types(chunk_as_dicts)
|
||||||
else:
|
else:
|
||||||
column_types = suggest_column_types(chunk)
|
column_types = suggest_column_types(chunk) # type: ignore[arg-type]
|
||||||
if extracts:
|
if extracts:
|
||||||
for col in extracts:
|
for col in extracts:
|
||||||
if col in column_types:
|
if col in column_types:
|
||||||
|
|
@ -3585,9 +3585,9 @@ class Table(Queryable):
|
||||||
if hash_id:
|
if hash_id:
|
||||||
all_columns.insert(0, hash_id)
|
all_columns.insert(0, hash_id)
|
||||||
else:
|
else:
|
||||||
all_columns_set = set()
|
all_columns_set: Set[str] = set()
|
||||||
for record in chunk:
|
for record in chunk:
|
||||||
all_columns_set.update(record.keys())
|
all_columns_set.update(record.keys()) # type: ignore[union-attr]
|
||||||
all_columns = list(sorted(all_columns_set))
|
all_columns = list(sorted(all_columns_set))
|
||||||
if hash_id:
|
if hash_id:
|
||||||
all_columns.insert(0, hash_id)
|
all_columns.insert(0, hash_id)
|
||||||
|
|
@ -3810,7 +3810,7 @@ class Table(Queryable):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
return rows[0][pk]
|
return rows[0][pk] # type: ignore[index]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return self.insert(
|
return self.insert(
|
||||||
combined_values,
|
combined_values,
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ class ValueTracker:
|
||||||
|
|
||||||
def test_integer(self, value: object) -> bool:
|
def test_integer(self, value: object) -> bool:
|
||||||
try:
|
try:
|
||||||
int(value) # type: ignore[arg-type]
|
int(value) # type: ignore
|
||||||
return True
|
return True
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return False
|
return False
|
||||||
|
|
@ -504,7 +504,7 @@ class NullProgressBar:
|
||||||
self.args = args
|
self.args = args
|
||||||
|
|
||||||
def __iter__(self) -> Iterator[T]:
|
def __iter__(self) -> Iterator[T]:
|
||||||
yield from self.args[0]
|
yield from self.args[0] # type: ignore
|
||||||
|
|
||||||
def update(self, value: int) -> None:
|
def update(self, value: int) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue