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 stubs for contrib.postgres.operations. #1071

Merged
merged 3 commits into from
Jul 24, 2022
Merged
Changes from 1 commit
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
101 changes: 101 additions & 0 deletions django-stubs/contrib/postgres/operations.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
from typing import Dict, Literal, Tuple

from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations import AddConstraint, AddIndex, RemoveIndex
from django.db.migrations.operations.base import Operation
from django.db.migrations.state import ProjectState
from django.db.models.constraints import BaseConstraint

class CreateExtension(Operation):
reversible: bool = ...
name: str = ...
def __init__(self, name: str) -> None: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def extension_exists(self, schema_editor: BaseDatabaseSchemaEditor, extension: str) -> bool: ...
def describe(self) -> str: ...
@property
def migration_name_fragment(self) -> str: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is defined in Operation: https://github.com/django/django/blob/67d0c4644acfd7707be4a31e8976f865509b09ac/django/db/migrations/operations/base.py#L82-L88

Can you please make sure that all parent methods stubs are not redefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Updated.


class BloomExtension(CreateExtension):
def __init__(self) -> None: ...

class BtreeGinExtension(CreateExtension):
def __init__(self) -> None: ...
Expand All @@ -25,3 +45,84 @@ class TrigramExtension(CreateExtension):

class UnaccentExtension(CreateExtension):
def __init__(self) -> None: ...

class NotInTransactionMixin:
def _ensure_not_in_transaction(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...

class AddIndexConcurrently(NotInTransactionMixin, AddIndex):
atomic: Literal[False] = ...
def describe(self) -> str: ...
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...

class RemoveIndexConcurrently(NotInTransactionMixin, RemoveIndex):
atomic: Literal[False] = ...
def describe(self) -> str: ...
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...

class CollationOperation(Operation):
name: str
locale: str
provider: str
deterministic: bool
def __init__(self, name: str, locale: str, *, provider: str = ..., deterministic: bool = ...) -> None: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def deconstruct(self) -> Tuple[str, Tuple, Dict[str, str]]: ...
def create_collation(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
def remove_collation(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...

class CreateCollation(CollationOperation):
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self) -> str: ...
@property
def migration_name_fragment(self) -> str: ...

class RemoveCollation(CollationOperation):
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def describe(self) -> str: ...
@property
def migration_name_fragment(self) -> str: ...

class AddConstraintNotValid(AddConstraint):
def __init__(self, model_name: str, constraint: BaseConstraint) -> None: ...
def describe(self) -> str: ...
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
@property
def migration_name_fragment(self) -> str: ...

class ValidateConstraint(Operation):
model_name: str
name: str
def __init__(self, model_name: str, name: str) -> None: ...
def describe(self) -> str: ...
def database_forwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def database_backwards(
self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
) -> None: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
@property
def migration_name_fragment(self) -> str: ...
def deconstruct(self) -> Tuple[str, Tuple, Dict[str, str]]: ...