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. 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. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..733220c --- /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/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 + +- [ ] New feature / enhancement +- [ ] Bug fix +- [ ] Documentation +- [ ] Maintenance +- [ ] Other (please specify): 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/docs/source/api.rst b/docs/source/api.rst index f520aaa..9fb65c7 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:`flask_utils.errors.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:`~flask_utils.extension.FlaskUtils` class or to :meth:`~flask_utils.extension.FlaskUtils.init_app()`. .. code-block:: python - from flask_utils import register_error_handlers - register_error_handlers(app) + from flask import Flask + from flask_utils import FlaskUtils + + app = Flask(__name__) + utils = FlaskUtils(app, register_error_handlers=True) + + # OR + + utils = FlaskUtils() + utils.init_app(app, register_error_handlers=True) .. automodule:: flask_utils.errors :members: diff --git a/docs/source/conf.py b/docs/source/conf.py index 7f8666f..e321eb1 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", ] @@ -48,3 +49,5 @@ # -- Options for EPUB output epub_show_urls = "footnote" + +add_module_names = False 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 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..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:`flask_utils.extension.FlaskUtils` class - or to :meth:`flask_utils.extension.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 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