From 8499414d66873750a28437bd9fd270b0a52ccec2 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 20:11:30 +0200 Subject: [PATCH 01/14] Docs: Disabled the notfound extension due to a bug with the Flask theme --- docs/source/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7f8666f..80090d5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,7 +24,8 @@ "sphinx.ext.autosummary", "sphinx.ext.intersphinx", "sphinx.ext.viewcode", - "notfound.extension", + # notfound causes a bug with the flask theme, see https://github.com/readthedocs/sphinx-notfound-page/issues/148 + # "notfound.extension", "pallets_sphinx_themes", ] From 40f2d5df39b1a36c0fd1b86aa3ba2442bca0ab1f Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:03:52 +0100 Subject: [PATCH 02/14] Chore: Created a pull request template --- .github/pull_request_template.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..5a03e65 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,27 @@ + + + + +## Description + + +## Related Issue + +- [ ] Closes # +- [ ] Related to # + +## Checklist + + +- [ ] Checked that the pre-commit checks pass (see [your-first-code-contribution](https://github.com/Mews/flask-utils/blob/main/CONTRIBUTING.md#your-first-code-contribution) and also [pre-commit](https://docs.pymc.io/en/latest/contributing/python_style.html)) +- [ ] Checked that all the tests pass (see [your-first-code-contribution](https://github.com/Mews/flask-utils/blob/main/CONTRIBUTING.md#your-first-code-contribution)) +- [ ] Checked that your commit messages follow [the specified guidelines](https://github.com/Mews/flask-utils/blob/main/CONTRIBUTING.md#commit-messages) +- [ ] Added necessary documentation (docstrings and/or example notebooks, if applicable) + +## Type of change + +- [ ] New feature / enhancement +- [ ] Bug fix +- [ ] Documentation +- [ ] Maintenance +- [ ] Other (please specify): From 7a10013b671e0b45f68f8cf42cbfe06e1d621ee7 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Tue, 11 Jun 2024 08:13:09 +0100 Subject: [PATCH 03/14] Chore: Fix redirect links in pull request template Co-authored-by: Jules Lasne --- .github/pull_request_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5a03e65..733220c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -13,9 +13,9 @@ ## Checklist -- [ ] Checked that the pre-commit checks pass (see [your-first-code-contribution](https://github.com/Mews/flask-utils/blob/main/CONTRIBUTING.md#your-first-code-contribution) and also [pre-commit](https://docs.pymc.io/en/latest/contributing/python_style.html)) -- [ ] Checked that all the tests pass (see [your-first-code-contribution](https://github.com/Mews/flask-utils/blob/main/CONTRIBUTING.md#your-first-code-contribution)) -- [ ] Checked that your commit messages follow [the specified guidelines](https://github.com/Mews/flask-utils/blob/main/CONTRIBUTING.md#commit-messages) +- [ ] Checked that the pre-commit checks pass (see [your-first-code-contribution](https://github.com/Seluj78/flask-utils/blob/main/CONTRIBUTING.md#your-first-code-contribution) and also [pre-commit](https://docs.pymc.io/en/latest/contributing/python_style.html)) +- [ ] Checked that all the tests pass (see [your-first-code-contribution](https://github.com/Seluj78/flask-utils/blob/main/CONTRIBUTING.md#your-first-code-contribution)) +- [ ] Checked that your commit messages follow [the specified guidelines](https://github.com/Seluj78/flask-utils/blob/main/CONTRIBUTING.md#commit-messages) - [ ] Added necessary documentation (docstrings and/or example notebooks, if applicable) ## Type of change From f48554f9e9fe5caf0bef3085d7c0018a48761ae5 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:44:49 +0100 Subject: [PATCH 04/14] Chore: Create feature request template --- .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..b61a283 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea you'd like to see added to this library +title: "[Feature] " +labels: enhancement +assignees: '' + +--- + +Write a short description of your feature in the issue title + +**Describe the feature you'd like** +Describe in length the feature you'd like to see added to this library. + +**Is your feature request related to a problem?** +If applicable, describe the problem you have when using the library, and how this feature would solve it. +Ex.: It always frustrates me how... + +**Additional context** +Add any other context or screenshots about the feature request you think might be relevant. From 8b3ad07ec0073c63020a60d656e7d8937d82dbce Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:46:34 +0100 Subject: [PATCH 05/14] Chore: Create bug report template --- .github/ISSUE_TEMPLATE/bug_report.md | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..71aecae --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Report a bug to help improve the library +title: "[BUG] " +labels: bug +assignees: '' + +--- + +Write a short description of the bug in the issue title + +**Describe the bug** +Describe the bug in length here. + +**Expected behavior** +Describe what you expected to happen. + +**Real behavior** +Describe what actually happens. + +**To Reproduce** +List the steps needed to reproduce the bug: +1. ... +2. ... +etc... + +**Context/Environment** +Write here the information about the environment in which the bug happens, such as: +- Your operating system +- Your python version +- The version of flask-utils you're using + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem that you think might be relevant. From 82dee8a57bac1ebdca9c54494401f23ae710b64a Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Wed, 12 Jun 2024 12:01:30 +0200 Subject: [PATCH 06/14] CI/CD: Removed 72 chars limit on commit messages --- .github/workflows/lint-commits.yml | 4 ---- scripts/lint-commit.sh | 5 ----- 2 files changed, 9 deletions(-) diff --git a/.github/workflows/lint-commits.yml b/.github/workflows/lint-commits.yml index c992a48..0a25922 100644 --- a/.github/workflows/lint-commits.yml +++ b/.github/workflows/lint-commits.yml @@ -24,10 +24,6 @@ jobs: pattern: /^.+(\r?\n(\r?\n.*)*)?$/, error: "Empty line between commit title and body is missing", }, - { - pattern: /^.{0,72}(?:\r?\n(?:(.{0,72})|(.*?([a-z]+:\/\/)?(([a-zA-Z0-9_]|-)+\.)+[a-z]{2,}(:\d+)?([a-zA-Z_0-9@:%\+.~\?&/=]|-)+).*?))*$/, - error: "Commit message lines are too long (maximum allowed is 72 characters, except for URLs)", - }, { pattern: /^\S.*?\S: .+/, error: "Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)", diff --git a/scripts/lint-commit.sh b/scripts/lint-commit.sh index a233f63..61bba2f 100755 --- a/scripts/lint-commit.sh +++ b/scripts/lint-commit.sh @@ -48,10 +48,5 @@ while read -r line; do error "Commit title ends in a period" fi - url_pattern="([a-z]+:\/\/)?(([a-zA-Z0-9_]|-)+\.)+[a-z]{2,}(:\d+)?([a-zA-Z_0-9@:%\+.~\?&\/=]|-)+" - if [[ $line_length -gt 72 ]] && (echo "$line" | grep -E -v -q "$url_pattern"); then - error "Commit message lines are too long (maximum allowed is 72 characters)" - fi - done <"$commit_file" exit 0 From 625a4f72c461b56d4e159ffcb3112f6632473a91 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:36:37 +0100 Subject: [PATCH 07/14] Docs: Hide full links in docs --- docs/source/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 80090d5..2aa7fcb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -49,3 +49,5 @@ # -- Options for EPUB output epub_show_urls = "footnote" + +add_module_names = False \ No newline at end of file From 8c99f37dfe81e30d25bcb0bb983c67fb1a745acb Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:41:38 +0100 Subject: [PATCH 08/14] Docs: Add newline at the end of conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2aa7fcb..e321eb1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -50,4 +50,4 @@ # -- Options for EPUB output epub_show_urls = "footnote" -add_module_names = False \ No newline at end of file +add_module_names = False From 6e867d23e3c84a858f3ba8dc22973e70625f2f2c Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:46:10 +0100 Subject: [PATCH 09/14] Docs: Removed hard coded links --- docs/source/api.rst | 2 +- flask_utils/decorators.py | 2 +- flask_utils/errors/__init__.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index f520aaa..d98493c 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -16,7 +16,7 @@ Custom exceptions ----------------- .. warning:: For any of these errors to work, you need to register the error handlers in your Flask app. - To do this, you can call :meth:`flask_utils.errors.register_error_handlers` with your Flask app as an argument. + To do this, you can call :meth:`register_error_handlers` with your Flask app as an argument. .. code-block:: python diff --git a/flask_utils/decorators.py b/flask_utils/decorators.py index 68960e5..07b4849 100644 --- a/flask_utils/decorators.py +++ b/flask_utils/decorators.py @@ -186,7 +186,7 @@ def validate_params( and the values are the expected types. :param allow_empty: Allow empty values for parameters. Defaults to False. - :raises flask_utils.errors.badrequest.BadRequestError: If the JSON body is malformed, + :raises BadRequestError: If the JSON body is malformed, the Content-Type header is missing or incorrect, required parameters are missing, or parameters are of the wrong type. diff --git a/flask_utils/errors/__init__.py b/flask_utils/errors/__init__.py index 13c55e9..91c87a9 100644 --- a/flask_utils/errors/__init__.py +++ b/flask_utils/errors/__init__.py @@ -24,8 +24,8 @@ def _register_error_handlers(application: Flask) -> None: .. versionchanged:: 0.5.0 Made the function private. If you want to register the custom error handlers, you need to - pass `register_error_handlers=True` to the :class:`flask_utils.extension.FlaskUtils` class - or to :meth:`flask_utils.extension.FlaskUtils.init_app` + pass `register_error_handlers=True` to the :class:`FlaskUtils` class + or to :meth:`FlaskUtils.init_app` .. code-block:: python From a6dcc19bf7e5908f3ca5e6a3a41d65bc671c50a5 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Wed, 12 Jun 2024 08:45:19 +0100 Subject: [PATCH 10/14] Docs: Restore links to shortened paths --- flask_utils/errors/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flask_utils/errors/__init__.py b/flask_utils/errors/__init__.py index 91c87a9..3e89117 100644 --- a/flask_utils/errors/__init__.py +++ b/flask_utils/errors/__init__.py @@ -24,8 +24,8 @@ def _register_error_handlers(application: Flask) -> None: .. versionchanged:: 0.5.0 Made the function private. If you want to register the custom error handlers, you need to - pass `register_error_handlers=True` to the :class:`FlaskUtils` class - or to :meth:`FlaskUtils.init_app` + pass `register_error_handlers=True` to the :class:`~flask_utils.extension.FlaskUtils` class + or to :meth:`~flask_utils.extension.FlaskUtils.init_app` .. code-block:: python From 6565ee8acab46968961f9d3435a547d52d8688a7 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Wed, 12 Jun 2024 10:23:14 +0100 Subject: [PATCH 11/14] Docs: Remove deprecated `register_error_handlers` method in warning --- docs/source/api.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index d98493c..58f1702 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -16,12 +16,21 @@ Custom exceptions ----------------- .. warning:: For any of these errors to work, you need to register the error handlers in your Flask app. - To do this, you can call :meth:`register_error_handlers` with your Flask app as an argument. + + To do this, you need to pass :attr:`register_error_handlers=True` to the :class:`FlaskUtils` class or to :meth:`~FlaskUtils.init_app()`. .. code-block:: python + + from flask import Flask + from flask_utils import FlaskUtils + + app = Flask(__name__) + utils = FlaskUtils(app, register_error_handlers=True) + + # OR - from flask_utils import register_error_handlers - register_error_handlers(app) + utils = FlaskUtils() + utils.init_app(app, register_error_handlers=True) .. automodule:: flask_utils.errors :members: From 436fb5b66e7d4d89a918f5a3ad7572ec233b9fa3 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Wed, 12 Jun 2024 10:28:08 +0100 Subject: [PATCH 12/14] Docs: Use absolute qualified name to generate links This is more robust than letting sphinx look for FlaskUtils or init_app and create a link to the first thing it finds --- docs/source/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 58f1702..6c22efd 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -17,7 +17,7 @@ Custom exceptions .. warning:: For any of these errors to work, you need to register the error handlers in your Flask app. - To do this, you need to pass :attr:`register_error_handlers=True` to the :class:`FlaskUtils` class or to :meth:`~FlaskUtils.init_app()`. + To do this, you need to pass :attr:`register_error_handlers=True` to the :class:`~flask_utils.extension.FlaskUtils` class or to :meth:`~flask_utils.extension.FlaskUtils.init_app()`. .. code-block:: python From ca53126ef90f9a4411535968ea44e86793a6f463 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Wed, 12 Jun 2024 10:45:34 +0100 Subject: [PATCH 13/14] Docs: Remove trailing whitespace in `api.rst` --- docs/source/api.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 6c22efd..9fb65c7 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -20,10 +20,10 @@ Custom exceptions To do this, you need to pass :attr:`register_error_handlers=True` to the :class:`~flask_utils.extension.FlaskUtils` class or to :meth:`~flask_utils.extension.FlaskUtils.init_app()`. .. code-block:: python - + from flask import Flask from flask_utils import FlaskUtils - + app = Flask(__name__) utils = FlaskUtils(app, register_error_handlers=True) From 2446363346f494b1f937b0fdf547ca757081f028 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Wed, 12 Jun 2024 12:04:25 +0200 Subject: [PATCH 14/14] Chore: Version update --- flask_utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask_utils/__init__.py b/flask_utils/__init__.py index bca407c..9f709a7 100644 --- a/flask_utils/__init__.py +++ b/flask_utils/__init__.py @@ -1,5 +1,5 @@ # Increment versions here according to SemVer -__version__ = "0.5.0" +__version__ = "0.5.1" from flask_utils.errors import ConflictError from flask_utils.errors import ForbiddenError