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

Complete Flask-Migrate and mark as Strict #34

Closed
wants to merge 2 commits into from
Closed
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: 0 additions & 1 deletion pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"stubs/commonmark",
"stubs/dateparser",
"stubs/docutils",
"stubs/Flask-Migrate",
"stubs/Flask-SocketIO",
"stubs/fpdf2",
"stubs/google-cloud-ndb",
Expand Down
2 changes: 2 additions & 0 deletions stubs/Flask-Migrate/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Flask-Migrate users don't need to interact with this undocumented module from within python
flask_migrate.cli
10 changes: 3 additions & 7 deletions stubs/Flask-Migrate/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
version = "4.0.*"
upstream_repository = "https://github.com/miguelgrinberg/flask-migrate"
# Requires versions of flask and Flask-SQLAlchemy with `py.typed` files
requires = ["Flask>=2.0.0", "Flask-SQLAlchemy>=3.0.1"]
partial_stub = true

[tool.stubtest]
ignore_missing_stub = true
upstream_repository = "https://github.com/miguelgrinberg/Flask-Migrate"
# Requires versions of Flask and Flask-SQLAlchemy with `py.typed` files
requires = ["Flask-SQLAlchemy>=3.0.1", "Flask>=2.0.0", "alembic"]
34 changes: 26 additions & 8 deletions stubs/Flask-Migrate/flask_migrate/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
import sys
from _typeshed import StrPath, SupportsKeysAndGetItem
from argparse import Namespace
from collections.abc import Callable, Iterable, Sequence
from logging import Logger
from typing import Any, TypeVar
from typing import Any, TextIO, TypeVar
from typing_extensions import ParamSpec, TypeAlias

import flask
from alembic.config import Config as AlembicConfig
from flask_sqlalchemy import SQLAlchemy

_T = TypeVar("_T")
_P = ParamSpec("_P")
_ConfigureCallback: TypeAlias = Callable[[Config], Config]
_AlembicConfigValue: TypeAlias = Any

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

class Config: # should inherit from alembic.config.Config which is not possible yet
class Config(AlembicConfig):
template_directory: str | None
def __init__(self, *args, **kwargs) -> None: ...
# Same as alembic.config.Config + template_directory kwarg
def __init__(
self,
file_: StrPath | None = None,
ini_section: str = "alembic",
output_buffer: TextIO | None = None,
stdout: TextIO = sys.stdout,
cmd_opts: Namespace | None = None,
config_args: SupportsKeysAndGetItem[str, _AlembicConfigValue] | Iterable[tuple[str, _AlembicConfigValue]] = ...,
attributes: SupportsKeysAndGetItem[str, _AlembicConfigValue] | Iterable[tuple[str, _AlembicConfigValue]] | None = None,
*,
template_directory: str | None = None,
) -> None: ...
def get_template_directory(self) -> str: ...

class Migrate:
configure_callbacks: list[_ConfigureCallback]
db: SQLAlchemy | None
directory: str
alembic_ctx_kwargs: dict[str, Any]
alembic_ctx_kwargs: dict[str, _AlembicConfigValue]
def __init__(
self,
app: flask.Flask | None = None,
Expand All @@ -31,7 +48,7 @@ class Migrate:
command: str = "db",
compare_type: bool = True,
render_as_batch: bool = True,
**kwargs,
**kwargs: _AlembicConfigValue,
) -> None: ...
def init_app(
self,
Expand All @@ -41,13 +58,13 @@ class Migrate:
command: str | None = None,
compare_type: bool | None = None,
render_as_batch: bool | None = None,
**kwargs,
**kwargs: _AlembicConfigValue,
) -> None: ...
def configure(self, f: _ConfigureCallback) -> _ConfigureCallback: ...
def call_configure_callbacks(self, config: Config): ...
def call_configure_callbacks(self, config: Config) -> Config: ...
def get_config(
self, directory: str | None = None, x_arg: str | Sequence[str] | None = None, opts: Iterable[str] | None = None
): ...
) -> Config: ...

def catch_errors(f: Callable[_P, _T]) -> Callable[_P, _T]: ...
def list_templates() -> None: ...
Expand Down Expand Up @@ -104,3 +121,4 @@ def heads(directory: str | None = None, verbose: bool = False, resolve_dependenc
def branches(directory: str | None = None, verbose: bool = False) -> None: ...
def current(directory: str | None = None, verbose: bool = False) -> None: ...
def stamp(directory: str | None = None, revision: str = "head", sql: bool = False, tag: str | None = None) -> None: ...
def check(directory: str | None = None) -> None: ...
Loading