From 941159e786cf807075e36b8fe6d60e6dd1a90b40 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Wed, 9 Aug 2023 15:07:02 +0300 Subject: [PATCH 1/7] Update lint engines versions --- .pre-commit-config.yaml | 14 +++++++------- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fcb6271a..d577c147 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 382e5223..94529213 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dynamic = ["version"] 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", From c940ccc468d0d5ffef3b71fe7a6d94579648f4a5 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Thu, 10 Aug 2023 23:47:27 +0300 Subject: [PATCH 2/7] Update pyproject.toml and toml format config --- .editorconfig | 2 +- pyproject.toml | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index e970de6d..b3cd1ef3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 94529213..e486fbe7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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", @@ -39,10 +40,10 @@ keywords = [ "extension" ] authors = [ - {name = "Ross Lawley", email = "ross.lawley@gmail.com"} + { name = "Ross Lawley", email = "ross.lawley@gmail.com" } ] maintainers = [ - {name = "Andrey Shpak", email = "ashpak@ashpak.ru"} + { name = "Andrey Shpak", email = "ashpak@ashpak.ru" } ] dynamic = ["version"] @@ -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" @@ -127,4 +128,4 @@ filterwarnings = [ "ignore::ResourceWarning", "ignore::DeprecationWarning:flask_mongoengine", "ignore::DeprecationWarning:tests", - ] +] From 04c7827627de2588a174909bb4d00225af064c54 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Thu, 10 Aug 2023 23:49:50 +0300 Subject: [PATCH 3/7] Update *.py files after new black version installation --- flask_mongoengine/pagination.py | 1 - flask_mongoengine/wtf/fields.py | 1 - tests/test_db_fields.py | 1 - tests/test_forms.py | 8 -------- tests/test_json.py | 4 +++- tests/test_pagination.py | 1 - tests/test_session.py | 1 - 7 files changed, 3 insertions(+), 14 deletions(-) diff --git a/flask_mongoengine/pagination.py b/flask_mongoengine/pagination.py index 01b8b2ea..200711bd 100644 --- a/flask_mongoengine/pagination.py +++ b/flask_mongoengine/pagination.py @@ -9,7 +9,6 @@ class Pagination(object): def __init__(self, iterable, page, per_page): - if page < 1: abort(404) diff --git a/flask_mongoengine/wtf/fields.py b/flask_mongoengine/wtf/fields.py index 09b7be58..84e8774c 100644 --- a/flask_mongoengine/wtf/fields.py +++ b/flask_mongoengine/wtf/fields.py @@ -144,7 +144,6 @@ def __init__( blank_text="---", **kwargs, ): - super(QuerySetSelectMultipleField, self).__init__( label, validators, queryset, label_attr, allow_blank, blank_text, **kwargs ) diff --git a/tests/test_db_fields.py b/tests/test_db_fields.py index 52dac9c7..97689e41 100644 --- a/tests/test_db_fields.py +++ b/tests/test_db_fields.py @@ -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 ) diff --git a/tests/test_forms.py b/tests/test_forms.py index 43821222..90ecab7a 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -15,7 +15,6 @@ def test_binaryfield(app, db): - with app.test_request_context("/"): class Binary(db.Document): @@ -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): @@ -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): @@ -60,7 +55,6 @@ class MyChoices(db.Document): def test_emailfield(app, db): - with app.test_request_context("/"): class Email(db.Document): @@ -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): @@ -383,7 +376,6 @@ class User(db.Document): def test_unique_with(app, db): - with app.test_request_context("/"): class Item(db.Document): diff --git a/tests/test_json.py b/tests/test_json.py index 73b7de28..a09488a7 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -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") diff --git a/tests/test_pagination.py b/tests/test_pagination.py index e9d3f4fe..0e754235 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -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): diff --git a/tests/test_session.py b/tests/test_session.py index 312a68e9..8b506c72 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -7,7 +7,6 @@ @pytest.fixture(autouse=True) def setup_endpoints(app, db): - app.session_interface = MongoEngineSessionInterface(db) @app.route("/") From dc82dcf4c2fd5eafaa401a5c1a91571f62da76e4 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Thu, 10 Aug 2023 23:55:35 +0300 Subject: [PATCH 4/7] Update markdown files with new linting (Aug 2023) --- README.md | 2 -- docs/db_model.md | 7 +++---- docs/forms.md | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fe110aa9..a127fbf6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/db_model.md b/docs/db_model.md index 323e5893..820b87e5 100644 --- a/docs/db_model.md +++ b/docs/db_model.md @@ -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. @@ -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 diff --git a/docs/forms.md b/docs/forms.md index e0b5eb30..f54c8613 100644 --- a/docs/forms.md +++ b/docs/forms.md @@ -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 @@ -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 @@ -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 From 388a3cbbf6ce5815247d9049a033fab2f54cf0ef Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Fri, 11 Aug 2023 04:09:20 +0300 Subject: [PATCH 5/7] Fix linting session --- .github/workflows/linting.yml | 2 +- noxfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 15561633..0b7123ec 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,7 +19,7 @@ jobs: matrix: include: - name: "linting" - python: "3.7" + python: "3.11" steps: - uses: actions/checkout@v3 diff --git a/noxfile.py b/noxfile.py index a32d8a66..0e03c1f9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -42,7 +42,7 @@ 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") From 31876c1e9ea492295b119de76c20fad7d9da9df5 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Fri, 11 Aug 2023 04:28:31 +0300 Subject: [PATCH 6/7] Extend tests matrix --- .github/workflows/coverage.yml | 6 +++--- .github/workflows/tests.yml | 6 +++--- noxfile.py | 18 ++++++++++++------ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2fff225e..a4cb6849 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -20,7 +20,7 @@ jobs: mongodb-version: [5.0] include: - name: "coverage" - python: "3.10" + python: "3.11" steps: - uses: actions/checkout@v3 @@ -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 @@ -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" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8cc0612a..03aa3e8c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 diff --git a/noxfile.py b/noxfile.py index 0e03c1f9..b719e7f7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -49,7 +49,9 @@ def lint(session): 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]) @@ -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]) @@ -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: @@ -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) From e20b534dc012959f883d1c7252eec39a779cbdb6 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Fri, 11 Aug 2023 06:31:09 +0300 Subject: [PATCH 7/7] Temporary disable warnings --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e486fbe7..30334f58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,6 +126,7 @@ testpaths = ["tests"] filterwarnings = [ "error", "ignore::ResourceWarning", + "ignore::DeprecationWarning", "ignore::DeprecationWarning:flask_mongoengine", "ignore::DeprecationWarning:tests", ]