Skip to content

Add stubs for flask-migrate #8967

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

Merged
merged 6 commits into from
Nov 22, 2022
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
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"stubs/cryptography",
"stubs/dateparser",
"stubs/docutils",
"stubs/Flask-Migrate",
"stubs/Flask-SQLAlchemy",
"stubs/fpdf2",
"stubs/html5lib",
Expand Down
2 changes: 2 additions & 0 deletions stubs/Flask-Migrate/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "4.0.*"
requires = ["types-Flask-SQLAlchemy"]
106 changes: 106 additions & 0 deletions stubs/Flask-Migrate/flask_migrate/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from collections.abc import Callable, Iterable, Sequence
from logging import Logger
from typing import Any, TypeVar
from typing_extensions import ParamSpec, TypeAlias

from flask_sqlalchemy import SQLAlchemy

_T = TypeVar("_T")
_P = ParamSpec("_P")
_App: TypeAlias = Any # flask.Flask is not possible as a dependency yet
_ConfigureCallback: TypeAlias = Callable[[Config], Config]

alembic_version: tuple[int, int, int]
log: Logger

class Config: # should inherit from alembic.config.Config which is not possible yet
template_directory: str | None
def __init__(self, *args, **kwargs) -> None: ...
def get_template_directory(self) -> str: ...

class Migrate:
configure_callbacks: list[_ConfigureCallback]
db: SQLAlchemy | None
directory: str
alembic_ctx_kwargs: dict[str, Any]
def __init__(
self,
app: _App | None = ...,
db: SQLAlchemy | None = ...,
directory: str = ...,
command: str = ...,
compare_type: bool = ...,
render_as_batch: bool = ...,
**kwargs,
) -> None: ...
def init_app(
self,
app: _App,
db: SQLAlchemy | None = ...,
directory: str | None = ...,
command: str | None = ...,
compare_type: bool | None = ...,
render_as_batch: bool | None = ...,
**kwargs,
) -> None: ...
def configure(self, f: _ConfigureCallback) -> _ConfigureCallback: ...
def call_configure_callbacks(self, config: Config): ...
def get_config(
self, directory: str | None = ..., x_arg: str | Sequence[str] | None = ..., opts: Iterable[str] | None = ...
): ...

def catch_errors(f: Callable[_P, _T]) -> Callable[_P, _T]: ...
def list_templates() -> None: ...
def init(directory: str | None = ..., multidb: bool = ..., template: str | None = ..., package: bool = ...) -> None: ...
def revision(
directory: str | None = ...,
message: str | None = ...,
autogenerate: bool = ...,
sql: bool = ...,
head: str = ...,
splice: bool = ...,
branch_label: str | None = ...,
version_path: str | None = ...,
rev_id: str | None = ...,
) -> None: ...
def migrate(
directory: str | None = ...,
message: str | None = ...,
sql: bool = ...,
head: str = ...,
splice: bool = ...,
branch_label: str | None = ...,
version_path: str | None = ...,
rev_id: str | None = ...,
x_arg: str | Sequence[str] | None = ...,
) -> None: ...
def edit(directory: str | None = ..., revision: str = ...) -> None: ...
def merge(
directory: str | None = ...,
revisions: str = ...,
message: str | None = ...,
branch_label: str | None = ...,
rev_id: str | None = ...,
) -> None: ...
def upgrade(
directory: str | None = ...,
revision: str = ...,
sql: bool = ...,
tag: str | None = ...,
x_arg: str | Sequence[str] | None = ...,
) -> None: ...
def downgrade(
directory: str | None = ...,
revision: str = ...,
sql: bool = ...,
tag: str | None = ...,
x_arg: str | Sequence[str] | None = ...,
) -> None: ...
def show(directory: str | None = ..., revision: str = ...) -> None: ...
def history(
directory: str | None = ..., rev_range: str | None = ..., verbose: bool = ..., indicate_current: bool = ...
) -> None: ...
def heads(directory: str | None = ..., verbose: bool = ..., resolve_dependencies: bool = ...) -> None: ...
def branches(directory: str | None = ..., verbose: bool = ...) -> None: ...
def current(directory: str | None = ..., verbose: bool = ...) -> None: ...
def stamp(directory: str | None = ..., revision: str = ..., sql: bool = ..., tag: str | None = ...) -> None: ...