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

Add async support for Quart+Flask #470

Merged
merged 43 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bdc1661
Replace black+isort+flake8 with ruff; add more async support
jace May 13, 2024
cf3ea94
Add async support to load_models
jace May 15, 2024
65456bf
Add async support to ClassView and ModelView (untested)
jace May 15, 2024
0cafa2e
Use Coroutine instead of Awaitable
jace May 15, 2024
1aa0942
Make `endpoint_for` work in both Quart and Flask (first tested to be …
jace May 16, 2024
0bb4618
Drop `--ignore-flaky` since it's unused in local dev
jace May 16, 2024
1897397
Drop fallback to asyncio.create_task
jace May 16, 2024
ab589da
Add docstrings
jace May 16, 2024
dc06e4e
Drop coaster.db
jace May 17, 2024
4e0e777
Update documentation
jace May 17, 2024
039dfea
Fix type hints for load_models
jace May 17, 2024
c1a02f5
Make redirect an exception in load_models
jace May 17, 2024
0a585f4
Make return type covariant
jace May 17, 2024
d089da4
Support async and Quart in `requestargs` and change datasource from `…
jace May 17, 2024
987ec96
Improved `ensure_sync` and `sync_await`
jace May 17, 2024
676f888
Use ABCs for isinstance checks
jace May 17, 2024
487a262
More cross-compatible helper functions
jace May 17, 2024
da31d7a
Allow empty yields in sync_await and document the shortcomings
jace May 19, 2024
0a97118
Support async in render_with
jace May 19, 2024
916fb25
Relax render_with render callable's return type spec
jace May 19, 2024
b071b64
Resolved type-ignores
jace May 19, 2024
f8f01f4
Use app's response class
jace May 20, 2024
97feca3
Assert response type
jace May 20, 2024
d4bd374
Implement Container and MutableMapping APIs in cross-wrapper proxies
jace May 20, 2024
55f5090
Merge branch 'main' into async
jace May 20, 2024
9542dc4
Use the `g` wrapper directly
jace May 20, 2024
c4c86cb
Document warning for sync_await
jace May 20, 2024
f32bd41
Require Flask and Werkzeug >= 3.0
jace May 20, 2024
ae5231d
Gate typing-only import
jace May 20, 2024
e70bd1f
Default to timestamp with timezone
jace May 20, 2024
054f4ac
Minor cleanup
jace May 20, 2024
d412549
Fix type in tests
jace May 20, 2024
c444883
Merge branch 'main' into async
jace May 22, 2024
5eb9f44
App context wrappers
jace May 22, 2024
314dddc
Add Pagination, move Query into a separate module
jace May 22, 2024
601b1e3
Flask-SQLAlchemy is no longer a base dependency
jace May 22, 2024
410b8c4
Fix TOML config test
jace May 22, 2024
33f5122
Enable more Ruff rules
jace May 22, 2024
6b4d7a0
Revise SQLAlchemy imports and type hints
jace May 26, 2024
4894f36
Update ruff
jace May 26, 2024
4c6084f
Use `secrets` instead of `random`; clarify comment
jace May 26, 2024
0c5bcff
Use base class for type hint
jace May 26, 2024
1edf450
Minor cleanup
jace May 26, 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
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
psql -h localhost -U postgres coaster_test -c "grant all privileges on schema public to $(whoami); grant all privileges on all tables in schema public to $(whoami); grant all privileges on all sequences in schema public to $(whoami);"
- name: Test with pytest
run: |
pytest --ignore-flaky --showlocals --cov=coaster
pytest --showlocals --cov=coaster
- name: Prepare coverage report
run: |
mkdir -p coverage
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ __pycache__
.mypy_cache
.cache
.vscode
coverage/
monkeytype.sqlite3
41 changes: 5 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
skip: ['yesqa', 'no-commit-to-branch']
skip: ['no-commit-to-branch']
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py39-plus']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.4.5
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies: &flake8deps
- flake8-assertive
# - flake8-annotations
- flake8-blind-except
- flake8-builtins
- flake8-comprehensions
# - flake8-docstrings
- flake8-isort
- flake8-logging-format
- flake8-mutable
- flake8-print
- pep8-naming
- toml
- tomli
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
additional_dependencies:
- tomli
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
Expand All @@ -56,6 +28,7 @@ repos:
]
additional_dependencies:
- flask
- quart
- lxml-stubs
- sqlalchemy
- toml
Expand All @@ -66,11 +39,6 @@ repos:
- types-requests
- types-toml
- typing-extensions
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: *flake8deps
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand All @@ -88,6 +56,7 @@ repos:
]
additional_dependencies:
- flask
- quart
- sqlalchemy
- tomli
- repo: https://github.com/PyCQA/bandit
Expand Down
8 changes: 7 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.8.0 - Unreleased
------------------

* Added async support and cross-compatibility between Flask and Quart
* Dropped obsolete modules ``db``, ``gfm`` and ``nlp``

0.7.0 - Unreleased
------------------

Expand All @@ -20,7 +26,7 @@
repeat already logged values
* Dropped deprecated declared_attr_roles and set_roles
* Added ``__json__`` protocol in ``RoleMixin``
* Remove unicode_http_header
* Removed unicode_http_header
* ``loader`` and ``after_loader`` are deprecated in ``coaster.views.ModelView``
in favour of a unified ``load`` method
* ``coaster.db`` is deprecated as Flask-SQLAlchemy 3.0 has changed architecture
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Coaster: common patterns for Flask apps
=======================================
Coaster: common patterns for Flask and Quart apps
=================================================

|docs| |travis| |coveralls| |deepsource|

Coaster contains functions and db models for recurring patterns in Flask
Coaster contains functions and db models for recurring patterns in Flask and Quart
apps. Documentation is at https://coaster.readthedocs.org/. Coaster requires
Python 3.9 or later.

Expand Down
21 changes: 9 additions & 12 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
flake8
flake8-assertive
flake8-blind-except
flake8-builtins
flake8-coding
flake8-comprehensions
flake8-isort
flake8-logging-format
flake8-mutable
flake8-print>=5.0.0
isort
pep8-naming
mypy
pre-commit
pylint
ruff
toml
types-bleach
types-Markdown
types-pytz
types-PyYAML
types-requests
types-toml
typing-extensions
2 changes: 2 additions & 0 deletions docs/compat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.. automodule:: coaster.compat
:members:
21 changes: 0 additions & 21 deletions docs/db.rst

This file was deleted.

3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Coaster is available under the BSD license, the same license as Flask.
auth
views/index
sqlalchemy/index
db
nlp
compat

Indices and tables
==================
Expand Down
2 changes: 0 additions & 2 deletions docs/nlp.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/sqlalchemy/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

model
mixins
query
pagination
columns
functions
roles
Expand Down
2 changes: 2 additions & 0 deletions docs/sqlalchemy/pagination.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.. automodule:: coaster.sqlalchemy.pagination
:members:
2 changes: 2 additions & 0 deletions docs/sqlalchemy/query.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.. automodule:: coaster.sqlalchemy.query
:members:
Loading
Loading