Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve types in DB backend schema modules #2124

Merged
merged 1 commit into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions django-stubs/contrib/gis/db/backends/mysql/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from logging import Logger
from typing import Any

from django.db.backends.mysql.schema import DatabaseSchemaEditor
from django.db.models.base import Model
from django.db.models.fields import Field

logger: Logger

Expand All @@ -10,9 +12,11 @@ class MySQLGISSchemaEditor(DatabaseSchemaEditor):
sql_drop_spatial_index: str
geometry_sql: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def skip_default(self, field: Any) -> Any: ...
def column_sql(self, model: Any, field: Any, include_default: bool = ...) -> Any: ...
def create_model(self, model: Any) -> None: ...
def add_field(self, model: Any, field: Any) -> None: ...
def remove_field(self, model: Any, field: Any) -> None: ...
def skip_default(self, field: Field) -> bool: ...
def column_sql(
self, model: type[Model], field: Field, include_default: bool = ...
) -> tuple[None, None] | tuple[str, list[Any]]: ...
def create_model(self, model: type[Model]) -> None: ...
def add_field(self, model: type[Model], field: Field) -> None: ...
def remove_field(self, model: type[Model], field: Field) -> None: ...
def create_spatial_indexes(self) -> None: ...
14 changes: 9 additions & 5 deletions django-stubs/contrib/gis/db/backends/oracle/schema.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Any

from django.db.backends.oracle.schema import DatabaseSchemaEditor
from django.db.models.base import Model
from django.db.models.fields import Field

class OracleGISSchemaEditor(DatabaseSchemaEditor):
sql_add_geometry_metadata: str
Expand All @@ -11,9 +13,11 @@ class OracleGISSchemaEditor(DatabaseSchemaEditor):
geometry_sql: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def geo_quote_name(self, name: Any) -> Any: ...
def column_sql(self, model: Any, field: Any, include_default: bool = ...) -> Any: ...
def create_model(self, model: Any) -> None: ...
def delete_model(self, model: Any) -> None: ...
def add_field(self, model: Any, field: Any) -> None: ...
def remove_field(self, model: Any, field: Any) -> None: ...
def column_sql(
self, model: type[Model], field: Field, include_default: bool = ...
) -> tuple[None, None] | tuple[str, list[Any]]: ...
def create_model(self, model: type[Model]) -> None: ...
def delete_model(self, model: type[Model]) -> None: ...
def add_field(self, model: type[Model], field: Field) -> None: ...
def remove_field(self, model: type[Model], field: Field) -> None: ...
def run_geometry_sql(self) -> None: ...
22 changes: 13 additions & 9 deletions django-stubs/contrib/gis/db/backends/spatialite/schema.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Any

from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.models.base import Model
from django.db.models.fields import Field

class SpatialiteSchemaEditor(DatabaseSchemaEditor):
sql_add_geometry_column: str
Expand All @@ -14,15 +16,17 @@ class SpatialiteSchemaEditor(DatabaseSchemaEditor):
geometry_sql: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def geo_quote_name(self, name: Any) -> Any: ...
def column_sql(self, model: Any, field: Any, include_default: bool = ...) -> Any: ...
def remove_geometry_metadata(self, model: Any, field: Any) -> None: ...
def create_model(self, model: Any) -> None: ...
def delete_model(self, model: Any, **kwargs: Any) -> None: ...
def add_field(self, model: Any, field: Any) -> None: ...
def remove_field(self, model: Any, field: Any) -> None: ...
def column_sql(
self, model: type[Model], field: Field, include_default: bool = ...
) -> tuple[None, None] | tuple[str, list[Any]]: ...
def remove_geometry_metadata(self, model: type[Model], field: Field) -> None: ...
def create_model(self, model: type[Model]) -> None: ...
def delete_model(self, model: type[Model], **kwargs: Any) -> None: ...
def add_field(self, model: type[Model], field: Field) -> None: ...
def remove_field(self, model: type[Model], field: Field) -> None: ...
def alter_db_table(
self,
model: Any,
old_db_table: Any,
new_db_table: Any,
model: type[Model],
old_db_table: str,
new_db_table: str,
) -> None: ...
12 changes: 6 additions & 6 deletions django-stubs/db/backends/base/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class BaseDatabaseSchemaEditor(AbstractContextManager[Any]):
def column_sql(
self, model: type[Model], field: Field, include_default: bool = ...
) -> tuple[None, None] | tuple[str, list[Any]]: ...
def skip_default(self, field: Any) -> bool: ...
def skip_default_on_alter(self, field: Any) -> bool: ...
def skip_default(self, field: Field) -> bool: ...
def skip_default_on_alter(self, field: Field) -> bool: ...
def prepare_default(self, value: Any) -> Any: ...
def db_default_sql(self, field: Field) -> _AsSqlType: ...
def effective_default(self, field: Field) -> int | str: ...
Expand All @@ -101,10 +101,10 @@ class BaseDatabaseSchemaEditor(AbstractContextManager[Any]):
) -> None: ...
def alter_db_table(self, model: type[Model], old_db_table: str, new_db_table: str) -> None: ...
def alter_db_table_comment(
self, model: type[Model], old_db_table_comment: str | None, new_db_table_comment: str
self, model: type[Model], old_db_table_comment: str, new_db_table_comment: str
) -> None: ...
def alter_db_tablespace(self, model: Any, old_db_tablespace: Any, new_db_tablespace: Any) -> None: ...
def add_field(self, model: Any, field: Any) -> None: ...
def remove_field(self, model: Any, field: Any) -> None: ...
def alter_db_tablespace(self, model: type[Model], old_db_tablespace: str, new_db_tablespace: str) -> None: ...
def add_field(self, model: type[Model], field: Field) -> None: ...
def remove_field(self, model: type[Model], field: Field) -> None: ...
def alter_field(self, model: type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ...
def remove_procedure(self, procedure_name: Any, param_types: Any = ...) -> None: ...
6 changes: 4 additions & 2 deletions django-stubs/db/backends/mysql/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from typing import Any

from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.mysql.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.fields import Field

class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
connection: DatabaseWrapper
Expand All @@ -22,5 +24,5 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
@property
def sql_rename_column(self) -> str: ... # type: ignore[override]
def quote_value(self, value: Any) -> str: ...
def skip_default(self, field: Any) -> bool: ...
def add_field(self, model: Any, field: Any) -> None: ...
def skip_default(self, field: Field) -> bool: ...
def add_field(self, model: type[Model], field: Field) -> None: ...
8 changes: 5 additions & 3 deletions django-stubs/db/backends/oracle/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from typing import Any

from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.oracle.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.fields import Field

class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
connection: DatabaseWrapper
Expand All @@ -16,8 +18,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_delete_table: str
sql_create_index: str
def quote_value(self, value: Any) -> str: ...
def remove_field(self, model: Any, field: Any) -> None: ...
def delete_model(self, model: Any) -> None: ...
def alter_field(self, model: Any, old_field: Any, new_field: Any, strict: bool = ...) -> None: ...
def remove_field(self, model: type[Model], field: Field) -> None: ...
def delete_model(self, model: type[Model]) -> None: ...
def alter_field(self, model: type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ...
def normalize_name(self, name: Any) -> str: ...
def prepare_default(self, value: Any) -> Any: ...
6 changes: 4 additions & 2 deletions django-stubs/db/backends/postgresql/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from typing import Any

from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.postgresql.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.indexes import Index

class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
connection: DatabaseWrapper
Expand All @@ -17,5 +19,5 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_delete_fk: str
sql_delete_procedure: str
def quote_value(self, value: Any) -> str: ...
def add_index(self, model: Any, index: Any, concurrently: bool = ...) -> None: ...
def remove_index(self, model: Any, index: Any, concurrently: bool = ...) -> None: ...
def add_index(self, model: type[Model], index: Index, concurrently: bool = ...) -> None: ...
def remove_index(self, model: type[Model], index: Index, concurrently: bool = ...) -> None: ...
Loading