From 8b048c20d5bbeeb95e48d4f1e948eaca8ba1e368 Mon Sep 17 00:00:00 2001 From: Vad Date: Tue, 9 Sep 2025 14:28:28 +0200 Subject: [PATCH 1/5] Update README.rst --- README.rst | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/README.rst b/README.rst index 72579da..fa08f53 100644 --- a/README.rst +++ b/README.rst @@ -14,32 +14,4 @@ Install package from PyPI. .. code-block:: text - pip install Flask-API-Framework - - -Links ------ - -- Documentation_ -- PyPI_ -- Source_ - -.. _Documentation: https://flask-api-framework.readthedocs.io/ -.. _PyPI: https://pypi.org/project/Flask-API-Framework/ -.. _Source: https://github.com/thnee/flask-api-framework - - -.. |GitHub tests| image:: https://github.com/thnee/flask-api-framework/actions/workflows/tests.yml/badge.svg - :target: https://github.com/thnee/flask-api-framework/actions - -.. |Documentation Status| image:: https://readthedocs.org/projects/flask-api-framework/badge/?version=latest - :target: https://flask-api-framework.readthedocs.io/en/latest/ - -.. |PyPI version| image:: https://img.shields.io/pypi/v/Flask-API-Framework?color=1283c4&label=version - :target: https://pypi.org/project/Flask-API-Framework/ - -.. |PyPI pyversions| image:: https://img.shields.io/pypi/pyversions/Flask-API-Framework.svg - :target: https://pypi.org/project/Flask-API-Framework/ - -.. |PyPI license| image:: https://img.shields.io/pypi/l/Flask-API-Framework.svg - :target: https://pypi.org/project/Flask-API-Framework/ + pip install "git+https://github.com/deristrat/flask-api-framework.git@main" From c05a3b1a62ed2668bb6376f3b61a6366c65ae14b Mon Sep 17 00:00:00 2001 From: Vad Date: Tue, 9 Sep 2025 14:38:05 +0200 Subject: [PATCH 2/5] Update LICENSE --- LICENSE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index b7b5493..b4a34d3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ BSD 3-Clause License -Copyright (c) 2022, Mattias Lindvall +Copyright (c) 2025, Njorda AB +Based on work Copyright (c) 2022, Mattias Lindvall All rights reserved. Redistribution and use in source and binary forms, with or without From 5c8ba9af768e0b72089f58604897f51b1143225a Mon Sep 17 00:00:00 2001 From: vad Date: Tue, 9 Sep 2025 16:01:52 +0200 Subject: [PATCH 3/5] update setup.py and pyproject.toml --- pyproject.toml | 8 +++----- setup.py | 31 ++++++++++++++----------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 74fb16a..e4acfb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,7 @@ addopts = ''' --quiet tests/ ''' -filterwarnings = [ - "ignore:SQLALCHEMY_TRACK_MODIFICATIONS:flask_sqlalchemy.FSADeprecationWarning", -] +filterwarnings = [] [tool.coverage.report] fail_under = 70 @@ -17,7 +15,7 @@ skip_covered = true [tool.black] line-length = 88 -target-version = ["py37", "py38", "py39", "py310"] +target-version = ["py37", "py38", "py39", "py310", "py311"] include = '\.pyi?$' exclude = ''' /( @@ -33,7 +31,7 @@ exclude = ''' [tool.isort] profile = "black" line_length = 88 -py_version = "310" +py_version = "311" lines_after_imports = 2 skip = [ ".git", diff --git a/setup.py b/setup.py index 031d58f..6aa10b9 100644 --- a/setup.py +++ b/setup.py @@ -3,38 +3,34 @@ setuptools.setup( name="Flask-API-Framework", - version="0.0.3", + version="0.0.4", keywords="flask api framework", description="Flask API Framework", long_description="Please see the project links.", project_urls={ - "Documentation": "https://flask-api-framework.readthedocs.io/", - "Source": "https://github.com/thnee/flask-api-framework", + "Source": "https://github.com/deristrat/flask-api-framework", }, license="BSD-3-Clause", - author="Mattias Lindvall", - author_email="mattias.lindvall@gmail.com", package_dir={"": "src"}, packages=["flask_api_framework"], python_requires=">=3.7", install_requires=[ "flask >= 2.0.0", - "marshmallow >= 3.14.0", + "marshmallow ~= 3.18.0", ], extras_require={ "test": [ - "flask-sqlalchemy ~= 2.5.1", + "flask-sqlalchemy ~= 3.0.5", "marshmallow-sqlalchemy ~= 0.28.0", - "flask-marshmallow ~= 0.14.0", - "pytest ~= 7.1.2", - "pytest-cov ~= 3.0.0", - "flake8 ~= 4.0.1", - "flake8-print ~= 5.0.0", - "flake8-bugbear ~= 22.4.25", - "black ~= 22.3.0", - "isort ~= 5.10.1", - "invoke ~= 1.7.1", - "tox ~= 3.25.0", + "flask-marshmallow ~= 0.15.0", + "pytest ~= 8.4.1", + "pytest-cov ~= 6.2.1", + "flake8 ~= 7.3.0", + "flake8-bugbear ~= 24.12.12", + "black ~= 23.12.1", + "isort ~= 6.0.1", + "invoke ~= 2.2.0", + "tox ~= 4.5.2", ], "build": [ "wheel ~= 0.37.1", @@ -55,6 +51,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development", "Intended Audience :: Developers", From 9b01ed594fb1197ad3f2a423fc911b08a75d4874 Mon Sep 17 00:00:00 2001 From: vad Date: Tue, 9 Sep 2025 16:02:13 +0200 Subject: [PATCH 4/5] replace schema instance with schema class --- examples/complete_db/blueprints/api_v1/views.py | 14 +++++++------- examples/minimal_db/main.py | 5 +++-- src/flask_api_framework/views.py | 12 +++++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/examples/complete_db/blueprints/api_v1/views.py b/examples/complete_db/blueprints/api_v1/views.py index 7862d71..1059545 100644 --- a/examples/complete_db/blueprints/api_v1/views.py +++ b/examples/complete_db/blueprints/api_v1/views.py @@ -18,7 +18,7 @@ class AuthorsIndex(af.List, af.Create): Same body schema for List and Create. """ - body_schema = AuthorSchema() + body_schema = AuthorSchema def get_instances(self): return Author.query.all() @@ -29,8 +29,8 @@ class AuthorsBooksList(af.List): List all books for a specific author defined by a view arg. """ - kwargs_schema = AuthorsBooksListKwargsSchema() - body_schema = BookListSchema() + kwargs_schema = AuthorsBooksListKwargsSchema + body_schema = BookListSchema def get_instances(self): q = Book.query @@ -45,8 +45,8 @@ class BooksIndex(af.List, af.Create): Different body schemas for List and Create. """ - list_body_schema = BookListSchema() - create_body_schema = BookCreateSchema() + list_body_schema = BookListSchema + create_body_schema = BookCreateSchema def get_instances(self): return Book.query.all() @@ -58,5 +58,5 @@ class BookDetail(af.Read, af.Update, af.Delete): Same body schema for Read, Update, Delete. """ - kwargs_schema = BookDetailKwargsSchema() - body_schema = BookDetailBodySchema() + kwargs_schema = BookDetailKwargsSchema + body_schema = BookDetailBodySchema diff --git a/examples/minimal_db/main.py b/examples/minimal_db/main.py index 2d6226b..fec3079 100644 --- a/examples/minimal_db/main.py +++ b/examples/minimal_db/main.py @@ -17,7 +17,8 @@ class Book(db.Model): title = db.Column(db.String(100)) -db.create_all() +with app.app_context(): + db.create_all() class BookSchema(ma.SQLAlchemyAutoSchema): @@ -28,7 +29,7 @@ class Meta: class Books(af.Create, af.List): - body_schema = BookSchema() + body_schema = BookSchema def get_instances(self): return Book.query.all() diff --git a/src/flask_api_framework/views.py b/src/flask_api_framework/views.py index 8befa49..2e8abc1 100644 --- a/src/flask_api_framework/views.py +++ b/src/flask_api_framework/views.py @@ -65,10 +65,10 @@ def dispatch_request(self, *args, **kwargs): raise ApiError(status_code=400, source="body") from e def load_kwargs_schema(self): - self.loaded_kwargs = self.kwargs_schema.load(data=flask.request.view_args) + self.loaded_kwargs = self.kwargs_schema().load(data=flask.request.view_args) def load_args_schema(self): - self.loaded_args = self.args_schema.load(data=flask.request.args) + self.loaded_args = self.args_schema().load(data=flask.request.args) def handle_kwargs(self, schema): try: @@ -111,7 +111,7 @@ def noop_data_wrapper(x): data_wrapper = noop_data_wrapper if schema is not None: return ( - flask.jsonify(data_wrapper(schema.dump(data, many=many))), + flask.jsonify(data_wrapper(schema().dump(data, many=many))), status_code, ) elif schema is None and data is not None: @@ -195,7 +195,9 @@ def handle_post(self, *args, **kwargs): return self.get_create_response() def load_create_request_body_schema(self): - self.loaded_body = self.create_request_body_schema.load(data=flask.request.json) + self.loaded_body = self.create_request_body_schema().load( + data=flask.request.json + ) def create(self): if is_sa_mapped(self.loaded_body): @@ -249,7 +251,7 @@ def load_update_request_body_schema(self, partial): ) if self.get_schema_load_instance(self.update_request_body_schema): kwargs["instance"] = self.instance - self.loaded_body = self.update_request_body_schema.load(**kwargs) + self.loaded_body = self.update_request_body_schema().load(**kwargs) def get_schema_load_instance(self, schema): try: From 308ae4d6c4f9efc27fb9858125744de037e63a60 Mon Sep 17 00:00:00 2001 From: vad Date: Tue, 9 Sep 2025 16:01:52 +0200 Subject: [PATCH 5/5] update setup.py and pyproject.toml --- pyproject.toml | 8 +++----- setup.py | 31 ++++++++++++++----------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 74fb16a..e4acfb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,7 @@ addopts = ''' --quiet tests/ ''' -filterwarnings = [ - "ignore:SQLALCHEMY_TRACK_MODIFICATIONS:flask_sqlalchemy.FSADeprecationWarning", -] +filterwarnings = [] [tool.coverage.report] fail_under = 70 @@ -17,7 +15,7 @@ skip_covered = true [tool.black] line-length = 88 -target-version = ["py37", "py38", "py39", "py310"] +target-version = ["py37", "py38", "py39", "py310", "py311"] include = '\.pyi?$' exclude = ''' /( @@ -33,7 +31,7 @@ exclude = ''' [tool.isort] profile = "black" line_length = 88 -py_version = "310" +py_version = "311" lines_after_imports = 2 skip = [ ".git", diff --git a/setup.py b/setup.py index 031d58f..6aa10b9 100644 --- a/setup.py +++ b/setup.py @@ -3,38 +3,34 @@ setuptools.setup( name="Flask-API-Framework", - version="0.0.3", + version="0.0.4", keywords="flask api framework", description="Flask API Framework", long_description="Please see the project links.", project_urls={ - "Documentation": "https://flask-api-framework.readthedocs.io/", - "Source": "https://github.com/thnee/flask-api-framework", + "Source": "https://github.com/deristrat/flask-api-framework", }, license="BSD-3-Clause", - author="Mattias Lindvall", - author_email="mattias.lindvall@gmail.com", package_dir={"": "src"}, packages=["flask_api_framework"], python_requires=">=3.7", install_requires=[ "flask >= 2.0.0", - "marshmallow >= 3.14.0", + "marshmallow ~= 3.18.0", ], extras_require={ "test": [ - "flask-sqlalchemy ~= 2.5.1", + "flask-sqlalchemy ~= 3.0.5", "marshmallow-sqlalchemy ~= 0.28.0", - "flask-marshmallow ~= 0.14.0", - "pytest ~= 7.1.2", - "pytest-cov ~= 3.0.0", - "flake8 ~= 4.0.1", - "flake8-print ~= 5.0.0", - "flake8-bugbear ~= 22.4.25", - "black ~= 22.3.0", - "isort ~= 5.10.1", - "invoke ~= 1.7.1", - "tox ~= 3.25.0", + "flask-marshmallow ~= 0.15.0", + "pytest ~= 8.4.1", + "pytest-cov ~= 6.2.1", + "flake8 ~= 7.3.0", + "flake8-bugbear ~= 24.12.12", + "black ~= 23.12.1", + "isort ~= 6.0.1", + "invoke ~= 2.2.0", + "tox ~= 4.5.2", ], "build": [ "wheel ~= 0.37.1", @@ -55,6 +51,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development", "Intended Audience :: Developers",