mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-28 04:44:26 +02:00
Apply no_implicit_optional codemod, closes #512
This commit is contained in:
parent
52ddb0b9ff
commit
965ca0d5f5
1 changed files with 20 additions and 20 deletions
|
|
@ -297,12 +297,12 @@ class Database:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
filename_or_conn: Union[str, pathlib.Path, sqlite3.Connection] = None,
|
filename_or_conn: Optional[Union[str, pathlib.Path, sqlite3.Connection]] = None,
|
||||||
memory: bool = False,
|
memory: bool = False,
|
||||||
memory_name: str = None,
|
memory_name: Optional[str] = None,
|
||||||
recreate: bool = False,
|
recreate: bool = False,
|
||||||
recursive_triggers: bool = True,
|
recursive_triggers: bool = True,
|
||||||
tracer: Callable = None,
|
tracer: Optional[Callable] = None,
|
||||||
use_counts_table: bool = False,
|
use_counts_table: bool = False,
|
||||||
):
|
):
|
||||||
assert (filename_or_conn is not None and (not memory and not memory_name)) or (
|
assert (filename_or_conn is not None and (not memory and not memory_name)) or (
|
||||||
|
|
@ -341,7 +341,7 @@ class Database:
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def tracer(self, tracer: Callable = None):
|
def tracer(self, tracer: Optional[Callable] = None):
|
||||||
"""
|
"""
|
||||||
Context manager to temporarily set a tracer function - all executed SQL queries will
|
Context manager to temporarily set a tracer function - all executed SQL queries will
|
||||||
be passed to this.
|
be passed to this.
|
||||||
|
|
@ -378,7 +378,7 @@ class Database:
|
||||||
|
|
||||||
def register_function(
|
def register_function(
|
||||||
self,
|
self,
|
||||||
fn: Callable = None,
|
fn: Optional[Callable] = None,
|
||||||
deterministic: bool = False,
|
deterministic: bool = False,
|
||||||
replace: bool = False,
|
replace: bool = False,
|
||||||
name: Optional[str] = None,
|
name: Optional[str] = None,
|
||||||
|
|
@ -879,7 +879,7 @@ class Database:
|
||||||
pk: Optional[Any] = None,
|
pk: Optional[Any] = None,
|
||||||
foreign_keys: Optional[ForeignKeysType] = None,
|
foreign_keys: Optional[ForeignKeysType] = None,
|
||||||
column_order: Optional[List[str]] = None,
|
column_order: Optional[List[str]] = None,
|
||||||
not_null: Iterable[str] = None,
|
not_null: Optional[Iterable[str]] = None,
|
||||||
defaults: Optional[Dict[str, Any]] = None,
|
defaults: Optional[Dict[str, Any]] = None,
|
||||||
hash_id: Optional[str] = None,
|
hash_id: Optional[str] = None,
|
||||||
hash_id_columns: Optional[Iterable[str]] = None,
|
hash_id_columns: Optional[Iterable[str]] = None,
|
||||||
|
|
@ -1129,7 +1129,7 @@ class Database:
|
||||||
sql += " [{}]".format(name)
|
sql += " [{}]".format(name)
|
||||||
self.execute(sql)
|
self.execute(sql)
|
||||||
|
|
||||||
def init_spatialite(self, path: str = None) -> bool:
|
def init_spatialite(self, path: Optional[str] = None) -> bool:
|
||||||
"""
|
"""
|
||||||
The ``init_spatialite`` method will load and initialize the SpatiaLite extension.
|
The ``init_spatialite`` method will load and initialize the SpatiaLite extension.
|
||||||
The ``path`` argument should be an absolute path to the compiled extension, which
|
The ``path`` argument should be an absolute path to the compiled extension, which
|
||||||
|
|
@ -1182,7 +1182,7 @@ class Queryable:
|
||||||
|
|
||||||
def count_where(
|
def count_where(
|
||||||
self,
|
self,
|
||||||
where: str = None,
|
where: Optional[str] = None,
|
||||||
where_args: Optional[Union[Iterable, dict]] = None,
|
where_args: Optional[Union[Iterable, dict]] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""
|
"""
|
||||||
|
|
@ -1213,12 +1213,12 @@ class Queryable:
|
||||||
|
|
||||||
def rows_where(
|
def rows_where(
|
||||||
self,
|
self,
|
||||||
where: str = None,
|
where: Optional[str] = None,
|
||||||
where_args: Optional[Union[Iterable, dict]] = None,
|
where_args: Optional[Union[Iterable, dict]] = None,
|
||||||
order_by: str = None,
|
order_by: Optional[str] = None,
|
||||||
select: str = "*",
|
select: str = "*",
|
||||||
limit: int = None,
|
limit: Optional[int] = None,
|
||||||
offset: int = None,
|
offset: Optional[int] = None,
|
||||||
) -> Generator[dict, None, None]:
|
) -> Generator[dict, None, None]:
|
||||||
"""
|
"""
|
||||||
Iterate over every row in this table or view that matches the specified where clause.
|
Iterate over every row in this table or view that matches the specified where clause.
|
||||||
|
|
@ -1251,11 +1251,11 @@ class Queryable:
|
||||||
|
|
||||||
def pks_and_rows_where(
|
def pks_and_rows_where(
|
||||||
self,
|
self,
|
||||||
where: str = None,
|
where: Optional[str] = None,
|
||||||
where_args: Optional[Union[Iterable, dict]] = None,
|
where_args: Optional[Union[Iterable, dict]] = None,
|
||||||
order_by: str = None,
|
order_by: Optional[str] = None,
|
||||||
limit: int = None,
|
limit: Optional[int] = None,
|
||||||
offset: int = None,
|
offset: Optional[int] = None,
|
||||||
) -> Generator[Tuple[Any, Dict], None, None]:
|
) -> Generator[Tuple[Any, Dict], None, None]:
|
||||||
"""
|
"""
|
||||||
Like ``.rows_where()`` but returns ``(pk, row)`` pairs - ``pk`` can be a single value or tuple.
|
Like ``.rows_where()`` but returns ``(pk, row)`` pairs - ``pk`` can be a single value or tuple.
|
||||||
|
|
@ -1345,7 +1345,7 @@ class Table(Queryable):
|
||||||
pk: Optional[Any] = None,
|
pk: Optional[Any] = None,
|
||||||
foreign_keys: Optional[ForeignKeysType] = None,
|
foreign_keys: Optional[ForeignKeysType] = None,
|
||||||
column_order: Optional[List[str]] = None,
|
column_order: Optional[List[str]] = None,
|
||||||
not_null: Iterable[str] = None,
|
not_null: Optional[Iterable[str]] = None,
|
||||||
defaults: Optional[Dict[str, Any]] = None,
|
defaults: Optional[Dict[str, Any]] = None,
|
||||||
batch_size: int = 100,
|
batch_size: int = 100,
|
||||||
hash_id: Optional[str] = None,
|
hash_id: Optional[str] = None,
|
||||||
|
|
@ -1545,7 +1545,7 @@ class Table(Queryable):
|
||||||
pk: Optional[Any] = None,
|
pk: Optional[Any] = None,
|
||||||
foreign_keys: Optional[ForeignKeysType] = None,
|
foreign_keys: Optional[ForeignKeysType] = None,
|
||||||
column_order: Optional[List[str]] = None,
|
column_order: Optional[List[str]] = None,
|
||||||
not_null: Iterable[str] = None,
|
not_null: Optional[Iterable[str]] = None,
|
||||||
defaults: Optional[Dict[str, Any]] = None,
|
defaults: Optional[Dict[str, Any]] = None,
|
||||||
hash_id: Optional[str] = None,
|
hash_id: Optional[str] = None,
|
||||||
hash_id_columns: Optional[Iterable[str]] = None,
|
hash_id_columns: Optional[Iterable[str]] = None,
|
||||||
|
|
@ -2464,7 +2464,7 @@ class Table(Queryable):
|
||||||
columns: Optional[Iterable[str]] = None,
|
columns: Optional[Iterable[str]] = None,
|
||||||
limit: Optional[int] = None,
|
limit: Optional[int] = None,
|
||||||
offset: Optional[int] = None,
|
offset: Optional[int] = None,
|
||||||
where: str = None,
|
where: Optional[str] = None,
|
||||||
where_args: Optional[Union[Iterable, dict]] = None,
|
where_args: Optional[Union[Iterable, dict]] = None,
|
||||||
quote: bool = False,
|
quote: bool = False,
|
||||||
) -> Generator[dict, None, None]:
|
) -> Generator[dict, None, None]:
|
||||||
|
|
@ -2527,7 +2527,7 @@ class Table(Queryable):
|
||||||
|
|
||||||
def delete_where(
|
def delete_where(
|
||||||
self,
|
self,
|
||||||
where: str = None,
|
where: Optional[str] = None,
|
||||||
where_args: Optional[Union[Iterable, dict]] = None,
|
where_args: Optional[Union[Iterable, dict]] = None,
|
||||||
analyze: bool = False,
|
analyze: bool = False,
|
||||||
) -> "Table":
|
) -> "Table":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue