Skip to content

Commit

Permalink
Merge branch '3.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jun 9, 2023
2 parents dc84727 + 3f15128 commit b3e876d
Show file tree
Hide file tree
Showing 24 changed files with 311 additions and 1,261 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ extend-ignore =
E722
# zip with strict=, requires python >= 3.10
B905
# string formatting opinion, B028 renamed to B907
B028
# string formatting opinion
B907
# up to 88 allowed by bugbear B950
max-line-length = 80
21 changes: 8 additions & 13 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ jobs:
with:
python-version: '3.x'
cache: 'pip'
cache-dependency-path: 'pdm.lock'
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ~/.cache/pdm
key: ${{ matrix.python }}-pdm-${{ hashFiles('pdm.lock') }}
restore-keys: ${{ matrix.python }}-pdm-
- run: pip install pdm
cache-dependency-path: 'requirements/*.txt'
- run: pip install build
# Use the commit date instead of the current date during the build.
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- run: pdm build
- run: python -m build
# Generate hashes used for provenance.
- name: generate hash
id: hash
Expand Down Expand Up @@ -63,15 +58,15 @@ jobs:
# files in the draft release.
environment: 'publish'
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
# Try uploading to Test PyPI first, in case something fails.
- uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: artifact/
repository-url: https://test.pypi.org/legacy/
packages-dir: artifact/
- uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598
with:
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: artifact/
packages-dir: artifact/
18 changes: 5 additions & 13 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
include:
- {name: '3.11', python: '3.11', tox: py311}
- {name: 'Lowest', python: '3.11', tox: py311-lowest}
- {name: 'Lowest', python: '3.11', tox: py311-min}
- {name: '3.10', python: '3.10', tox: py310}
- {name: '3.9', python: '3.9', tox: py39}
- {name: '3.8', python: '3.8', tox: py38}
Expand All @@ -37,20 +37,12 @@ jobs:
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: 'pdm.lock'
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ~/.cache/pdm
key: ${{ matrix.python }}-pdm-${{ hashFiles('pdm.lock') }}
restore-keys: ${{ matrix.python }}-pdm-
cache-dependency-path: 'requirements/*.txt'
- name: cache mypy
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ./.mypy_cache
key: mypy|${{ matrix.python }}|${{ hashFiles('pyproject.toml') }}
key: mypy|${{ matrix.python }}|${{ hashFiles('requirements/mypy.txt') }}
if: matrix.tox == 'typing'
- run: |
pip install pdm
pdm config install.cache true
pdm sync -dG tox
- run: pdm run tox -e ${{ matrix.tox }}
- run: pip install tox
- run: tox r -e ${{ matrix.tox }}
31 changes: 12 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
.DS_Store
*.pyc
*.pyo
*.egg-info/
dist/
build/
docs/_build/
.tox/
.idea/
.pytest_cache/
.mypy_cache/
htmlcov/
.coverage
.coverage.*
.vscode/
env/
venv/
.venv/
.pdm.toml
/.idea/
/.vscode/
/.venv/
__pycache__/
/dist/
/.pytest_cache/
/.coverage
/.coverage.*
/htmlcov/
/.mypy_cache/
/.tox/
/docs/_build/
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.4.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/asottile/reorder_python_imports
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
files: "^(?!examples/)"
args: ["--py37-plus", "--application-directories", "src"]
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
args: ["--target-version", "py37"]
Expand Down
9 changes: 5 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ build:
os: "ubuntu-22.04"
tools:
python: "3.11"
jobs:
post_install:
- "curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -"
- "VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH ~/.local/bin/pdm sync -dG docs"
python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
sphinx:
builder: dirhtml
fail_on_warning: true
37 changes: 20 additions & 17 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Include the following in your patch:
- Use `Black`_ to format your code. This and other tools will run
automatically if you install `pre-commit`_ using the instructions
below.
- All code and docs should be wrapped at 88 characters.
- Include tests if your patch adds or changes code. Make sure the test
fails without your patch.
- Update any relevant docs pages and docstrings.
Expand All @@ -87,43 +86,46 @@ First time setup
- Make sure you have a `GitHub account`_.
- Fork Flask-SQLAlchemy to your GitHub account by clicking the `Fork`_
button.
- `Clone`_ the main repository locally.
- `Clone`_ the main repository locally, replacing ``{username}`` with your GitHub
username.

.. code-block:: text
$ git clone https://github.com/pallets-eco/flask-sqlalchemy
$ git clone https://github.com/{username}/flask-sqlalchemy
$ cd flask-sqlalchemy
- Add your fork as a remote to push your work to. Replace
``{username}`` with your username. This names the remote "fork", the
default Pallets remote is "origin".
- Create a virtualenv.

.. code-block:: text
git remote add fork https://github.com/{username}/flask-sqlalchemy
$ python3 -m venv .venv
$ . .venv/bin/activate
- `Install PDM`_, the tool we use to manage the development environment.
On Windows, activating is different.

- Use PDM to set up the development environment. This automatically creates a
virtualenv, installs development tools, and installs the project in editable mode.
.. code-block:: text
> .venv\Scripts\activate
- Install the development dependencies, then install Flask-SQLAlchemy
in editable mode.

.. code-block:: text
$ pdm sync
$ pip install -r requirements/dev.txt && pip install -e .
- Install the pre-commit hooks.

.. code-block:: text
$ pdm run pre-commit install
$ pre-commit install
.. _latest version of git: https://git-scm.com/downloads
.. _username: https://docs.github.com/en/github/using-git/setting-your-username-in-git
.. _email: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address
.. _GitHub account: https://github.com/join
.. _Fork: https://github.com/pallets-eco/flask-sqlalchemy/fork
.. _Clone: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#step-2-create-a-local-clone-of-your-fork
.. _Install PDM: https://pdm.fming.dev/latest/#installation


Start coding
Expand Down Expand Up @@ -169,15 +171,15 @@ Run the basic test suite with pytest.

.. code-block:: text
$ pdm run pytest
$ pytest
This runs the tests for the current environment, which is usually sufficient. CI will
run the full suite when you submit your pull request. You can run the full test suite in
parallel with tox if you don't want to wait.

.. code-block:: text
$ pdm run tox -p
$ tox p
Running test coverage
Expand All @@ -188,8 +190,9 @@ contributing. Collect coverage from the tests and generate a report.

.. code-block:: text
$ pdm run pytest --cov
$ pdm run coverage html
$ pip install "coverage[toml]"
$ coverage run -m pytest
$ coverage html
Open ``htmlcov/index.html`` in your browser to explore the report.

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= pdm run sphinx-build
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

Expand Down
6 changes: 3 additions & 3 deletions docs/binds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ application context.
db.create_all()
# create tables for the default and "auth" binds
db.create_all(bind=[None, "auth"])
db.create_all(bind_key=[None, "auth"])
# create tables for the "meta" bind
db.create_all(bind="meta")
db.create_all(bind_key="meta")
# drop tables for the default bind
db.drop_all(bind=None)
db.drop_all(bind_key=None)
4 changes: 2 additions & 2 deletions docs/contexts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ a context for a specific test.
import pytest
@pytest.mark.fixture
@pytest.fixture
def app_ctx(app):
with app.app_context():
yield
@pytest.mark.usefixtures("app_ctx")
def test_user_model(app):
def test_user_model():
user = User()
db.session.add(user)
db.session.commit()
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pushd %~dp0
REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=pdm run sphinx-build
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
Expand Down

0 comments on commit b3e876d

Please sign in to comment.