Skip to content

Add peewee playhouse.flask_utils stubs #11731

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 27 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4498e93
Add peewee playhouse stubs
pylipp Apr 8, 2024
7a63745
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 8, 2024
5eb00c0
Add missing import
pylipp Apr 9, 2024
7be7f77
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2024
e0a5f6b
fix some simple things
AlexWaygood Apr 9, 2024
7a332c7
fix flake8
AlexWaygood Apr 9, 2024
2e95cac
Declare partial_stub
pylipp Apr 18, 2024
7904c11
Declare ignore_missing_stub
pylipp Apr 18, 2024
46b081d
Use stubtest_allowlist instead of ignore_missing_stub=true
pylipp Apr 19, 2024
a4d3438
Add missing flask_utils.* names to stubtest_allowlist
pylipp Apr 19, 2024
05b1057
Update stubs/peewee/METADATA.toml
pylipp Apr 19, 2024
954ed97
Remove types of private FlaskDB methods
pylipp Apr 19, 2024
c51ad9a
Add comment
pylipp Apr 19, 2024
39142ca
Update some FlaskDB method types
pylipp Apr 19, 2024
2af5f3a
Add type for get_model_class
pylipp Apr 19, 2024
1044bfe
Add Unused
pylipp Apr 19, 2024
9b7a04b
Merge branch 'main' into master
Avasam Apr 19, 2024
195cf9d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 19, 2024
5c841ba
Update stubs/peewee/playhouse/flask_utils.pyi
Avasam Apr 19, 2024
8b3b6f6
Update stubs/peewee/playhouse/flask_utils.pyi
Avasam Apr 19, 2024
500fcc4
Update stubs/peewee/playhouse/flask_utils.pyi
Avasam Apr 19, 2024
0364730
Update stubs/peewee/playhouse/flask_utils.pyi
pylipp Apr 19, 2024
3e3a635
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 19, 2024
6195847
Use ModelBase instead of Model
pylipp Apr 20, 2024
0f2bc77
Remove type of model_class parameter
pylipp Apr 23, 2024
b9c5cfc
Update stubs/peewee/playhouse/flask_utils.pyi
Avasam Apr 23, 2024
d5ad960
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 23, 2024
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
6 changes: 6 additions & 0 deletions stubs/peewee/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ peewee.DQ.__invert__
peewee.Window.as_groups
peewee.Window.as_range
peewee.Window.as_rows

# Ignore missing playhouse modules and names we don't currently provide
playhouse\.\w+?
playhouse.flask_utils.PaginatedQuery
playhouse.flask_utils.get_\w+
playhouse.flask_utils.object_list
8 changes: 8 additions & 0 deletions stubs/peewee/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
version = "3.17.3"
upstream_repository = "https://github.com/coleifer/peewee"
# We're not providing stubs for all playhouse modules right now
# https://github.com/python/typeshed/pull/11731#issuecomment-2065729058
partial_stub = true

[tool.stubtest]
stubtest_requirements = ["Flask>=2.0.0"]
# Using stubtest_allowlist to ignore playhouse modules we don't provide.
ignore_missing_stub = false
Empty file.
28 changes: 28 additions & 0 deletions stubs/peewee/playhouse/flask_utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from _typeshed import Unused
from collections.abc import Container
from typing import Any
from typing_extensions import TypeAlias

from peewee import Database, ModelBase, Proxy

# Is actually flask.Flask
_Flask: TypeAlias = Any

class FlaskDB:
# Omitting undocumented base_model_class on purpose, use FlaskDB.Model instead
database: Database | Proxy
def __init__(
self,
app: _Flask | None = None,
database: Database | Proxy | None = None,
# Is actually type[ModelClass] but stubtest likely confuses with Model property
# https://github.com/python/typeshed/pull/11731#issuecomment-2067694259
model_class=...,
excluded_routes: Container[str] | None = None,
) -> None: ...
def init_app(self, app: _Flask) -> None: ...
def get_model_class(self) -> type[ModelBase]: ...
@property
def Model(self) -> type[ModelBase]: ...
def connect_db(self) -> None: ...
def close_db(self, exc: Unused) -> None: ...