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

Update linting and ci/cd from 2022 to 2023 versions #530

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{html,css,scss,json,yml,tpl,js,jsx}]
[*.{html,css,scss,json,yml,tpl,js,jsx,toml}]
indent_style = space
indent_size = 2

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
mongodb-version: [5.0]
include:
- name: "coverage"
python: "3.10"
python: "3.11"

steps:
- uses: actions/checkout@v3
Expand All @@ -33,7 +33,7 @@ jobs:
python -m pip install --upgrade pip
pip install nox virtualenv
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.7.0
uses: supercharge/mongodb-github-action@v1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
- name: Test build
Expand All @@ -43,7 +43,7 @@ jobs:
with:
file: ./coverage.xml
- name: Send coverage report to codeclimate
uses: paambaati/codeclimate-action@v3.0.0
uses: paambaati/codeclimate-action@v5.0.0
continue-on-error: true
with:
coverageCommand: echo "Ignore rerun"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
include:
- name: "linting"
python: "3.7"
python: "3.11"

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
strategy:
fail-fast: false
matrix:
mongodb-version: ["3.6", "4.0", "4.2", "4.4", "5.0"]
python: ["3.7", "3.8", "3.9", "3.10", "pypy3.7"]
mongodb-version: ["3.6", "4.0", "4.2", "4.4", "5.0", "6.0"]
python: ["3.7", "3.8", "3.9", "3.10", "3.11.", "pypy3.7", "pypy3.8", "pypy3.9"]

steps:
- uses: actions/checkout@v3
Expand All @@ -30,7 +30,7 @@ jobs:
python -m pip install --upgrade pip
pip install nox virtualenv
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.7.0
uses: supercharge/mongodb-github-action@v1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
- name: Test build
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -24,23 +24,23 @@ repos:
args: [--remove]
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.7.0
hooks:
- id: black
language_version: python3.7
language_version: python3.11
exclude: ^docs/
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
exclude: ^docs/|^examples/
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
rev: v0.35.0
hooks:
- id: markdownlint
args: [-f]
exclude: ^(.github|tests)
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,4 @@ Flask-MongoEngine is distributed under [BSD 3-Clause License].

[Contribution guidelines]: CONTRIBUTING.md

[nox]: https://nox.thea.codes/en/stable/usage.html

[complete connection settings description]: http://docs.mongoengine.org/projects/flask-mongoengine/flask_config.html
7 changes: 3 additions & 4 deletions docs/db_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

```{important}
Flask-Mongoengine does not adjust database level behaviour of [mongoengine] fields
definition, except [keyword only definition] requirement. Everything other on
database level match [mongoengine] project. All parent methods, arguments (as
keyword arguments) and keyword arguments are supported.
definition, except [keyword only definition](#keyword-only-definition) requirement.
Everything other on database level match [mongoengine] project. All parent methods,
arguments (as keyword arguments) and keyword arguments are supported.

If you are not intend to use WTForms integration, you are free to use fields classes
from parent [mongoengine] project; this should not break anything.
Expand Down Expand Up @@ -44,4 +44,3 @@ check issue [#379] as example of one of such cases.
[mongoengine]: https://docs.mongoengine.org/
[#379]: https://github.com/MongoEngine/flask-mongoengine/issues/379
[integration]: forms
[keyword only definition]: #keyword-only-definition
6 changes: 2 additions & 4 deletions docs/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This allows to create several forms for same model, for different circumstances.

## Requirements

For correct integration behavior several requirements should be met:
For correct [integration] behavior several requirements should be met:

- Document classes should be used from Flask-Mongoengine
{class}`flask_mongoengine.MongoEngine` class, or from
Expand All @@ -41,7 +41,7 @@ For correct integration behavior several requirements should be met:

## Global transforms

For all fields, processed by Flask-Mongoengine integration:
For all fields, processed by Flask-Mongoengine [integration]:

- If model field definition have {attr}`wtf_validators` defined, they will be
forwarded to WTForm as {attr}`validators`. This is not protection from
Expand Down Expand Up @@ -1038,8 +1038,6 @@ Not yet documented. Please help us with new pull request.

[mongoengine]: https://docs.mongoengine.org/

[#379]: https://github.com/MongoEngine/flask-mongoengine/issues/379

[integration]: forms

[global transforms]: #global-transforms
Expand Down
1 change: 0 additions & 1 deletion flask_mongoengine/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class Pagination(object):
def __init__(self, iterable, page, per_page):

if page < 1:
abort(404)

Expand Down
1 change: 0 additions & 1 deletion flask_mongoengine/wtf/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def __init__(
blank_text="---",
**kwargs,
):

super(QuerySetSelectMultipleField, self).__init__(
label, validators, queryset, label_attr, allow_blank, blank_text, **kwargs
)
Expand Down
20 changes: 13 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ def base_install(session, flask, mongoengine, toolbar, wtf):
return session


@nox.session(python="3.7")
@nox.session(python="3.11")
def lint(session):
"""Run linting check locally."""
session.install("pre-commit")
session.run("pre-commit", "run", "-a")


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy3.7"])
@nox.session(
python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
)
@nox.parametrize("flask", ["==1.1.4", "==2.0.3", ">=2.1.2"])
@nox.parametrize("mongoengine", ["==0.21.0", "==0.22.1", "==0.23.1", ">=0.24.1"])
@nox.parametrize("toolbar", [True, False])
Expand Down Expand Up @@ -78,7 +80,9 @@ def _run_in_docker(session):
session.run_always("docker", "rm", "-fv", "nox_docker_test", external=True)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy3.7"])
@nox.session(
python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
)
@nox.parametrize("flask", ["==1.1.4", "==2.0.3", ">=2.1.2"])
@nox.parametrize("mongoengine", ["==0.21.0", "==0.22.1", "==0.23.1", ">=0.24.1"])
@nox.parametrize("toolbar", [True, False])
Expand All @@ -89,12 +93,14 @@ def full_tests(session, flask, mongoengine, toolbar, wtf):
_run_in_docker(session)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy3.7"])
@nox.session(
python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
)
@nox.parametrize("toolbar", [True, False])
@nox.parametrize("wtf", [True, False])
def latest(session, toolbar, wtf):
"""Run minimum tests for checking minimum code quality."""
flask = ">=2.1.2"
flask = "==2.1.3"
mongoengine = ">=0.24.1"
session = base_install(session, flask, mongoengine, toolbar, wtf)
if session.interactive:
Expand All @@ -103,13 +109,13 @@ def latest(session, toolbar, wtf):
session.run("pytest", *session.posargs)


@nox.session(python="3.10")
@nox.session(python="3.11")
def documentation_tests(session):
"""Run documentation tests."""
return docs(session, batch_run=True)


@nox.session(python="3.10")
@nox.session(python="3.11")
def docs(session, batch_run: bool = False):
"""Build the documentation or serve documentation interactively."""
shutil.rmtree(Path("docs").joinpath("_build"), ignore_errors=True)
Expand Down
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "flask-mongoengine"
description = "Flask extension that provides integration with MongoEngine and WTF model forms."
readme = "README.md"
requires-python = ">=3.7"
license = {text = "BSD 3-Clause License"}
license = { text = "BSD 3-Clause License" }
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
Expand All @@ -17,6 +17,7 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
Expand All @@ -39,18 +40,18 @@ keywords = [
"extension"
]
authors = [
{name = "Ross Lawley", email = "[email protected]"}
{ name = "Ross Lawley", email = "[email protected]" }
]
maintainers = [
{name = "Andrey Shpak", email = "[email protected]"}
{ name = "Andrey Shpak", email = "[email protected]" }
]
dynamic = ["version"]

[project.optional-dependencies]
wtf = ["WTForms[email]>=3.0.0", "Flask-WTF>=0.14.3"]
toolbar = ["Flask-DebugToolbar>=0.11.0"]
dev = [
"black==22.6.0",
"black==23.7.0",
"pre-commit",
"pytest",
"pytest-cov",
Expand Down Expand Up @@ -85,10 +86,10 @@ build-backend = "setuptools.build_meta"
[tool.setuptools]
zip-safe = false
platforms = ["any"]
packages=["flask_mongoengine", "flask_mongoengine.wtf"]
packages = ["flask_mongoengine", "flask_mongoengine.wtf"]

[tool.setuptools.dynamic]
version = {attr = "flask_mongoengine._version.version"}
version = { attr = "flask_mongoengine._version.version" }

[tool.setuptools_scm]
write_to = "flask_mongoengine/_version.py"
Expand Down Expand Up @@ -125,6 +126,7 @@ testpaths = ["tests"]
filterwarnings = [
"error",
"ignore::ResourceWarning",
"ignore::DeprecationWarning",
"ignore::DeprecationWarning:flask_mongoengine",
"ignore::DeprecationWarning:tests",
]
]
1 change: 0 additions & 1 deletion tests/test_db_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def test__get_fields_names__is_called_by_to_wtf_form_call(
def test__get_fields_names__hold_correct_fields_ordering_for_only(
self, TempDocument
):

field_names = TempDocument._get_fields_names(
only=["field_five", "field_one"], exclude=None
)
Expand Down
8 changes: 0 additions & 8 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


def test_binaryfield(app, db):

with app.test_request_context("/"):

class Binary(db.Document):
Expand All @@ -28,9 +27,7 @@ class Binary(db.Document):


def test_choices_coerce(app, db):

with app.test_request_context("/"):

CHOICES = ((1, "blue"), (2, "red"))

class MyChoices(db.Document):
Expand All @@ -44,9 +41,7 @@ class MyChoices(db.Document):


def test_list_choices_coerce(app, db):

with app.test_request_context("/"):

CHOICES = ((1, "blue"), (2, "red"))

class MyChoices(db.Document):
Expand All @@ -60,7 +55,6 @@ class MyChoices(db.Document):


def test_emailfield(app, db):

with app.test_request_context("/"):

class Email(db.Document):
Expand Down Expand Up @@ -343,7 +337,6 @@ class DogOwner(db.Document):

def test_modelradiofield(app, db):
with app.test_request_context("/"):

choices = [("male", "Male"), ("female", "Female"), ("other", "Other")]

class Poll(db.Document):
Expand Down Expand Up @@ -383,7 +376,6 @@ class User(db.Document):


def test_unique_with(app, db):

with app.test_request_context("/"):

class Item(db.Document):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ class DummyEncoder(flask.json.JSONEncoder):
"""


DummyProvider = None
if use_json_provider():

class DummyProvider(flask.json.provider.DefaultJSONProvider):
"""Dummy Provider, to test correct MRO in new flask versions."""

else:
DummyProvider = None


@pytest.mark.skipif(condition=use_json_provider(), reason="New flask use other test")
@pytest.mark.usefixtures("extended_db")
Expand Down
1 change: 0 additions & 1 deletion tests/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def _test_paginator(paginator):
assert [1, 2, 3, 4, 5] == list(paginator.iter_pages())

for i in [1, 2, 3, 4, 5]:

if i == 1:
assert not paginator.has_prev
with pytest.raises(NotFound):
Expand Down
1 change: 0 additions & 1 deletion tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

@pytest.fixture(autouse=True)
def setup_endpoints(app, db):

app.session_interface = MongoEngineSessionInterface(db)

@app.route("/")
Expand Down