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 dependencies and add tests for empty file field #552

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

uncle-lv
Copy link
Member

@uncle-lv uncle-lv commented Mar 19, 2024

Pin flask-marshmallow==1.2.1 for two important bug fixes below:

Pin flask==2.2.0 and werkzeug==2.2.0 because flask-marshmallow updated min version of flask.

Pin Flask-HTTPAuth==4.4.0 because safe_str_cmp is deprecated and has been removed in Werkzeug 2.1.

Update flake8 hook to 7.0.0 to be compatible with python3.12.

Add a test for empty file field.

@uncle-lv uncle-lv changed the title pin flask-marshmallow==1.2.1 and add tests pin flask-marshmallow==1.2.1 and add tests Mar 20, 2024
@@ -1,10 +1,10 @@
# minimum install requirements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to update this file. This file kept the minimal version supported by APIFlask and will only be used in testing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don't update this file, the new test will fail.

        rv = client.post(
            '/',
            data={
                'image': '',
            },
            content_type='multipart/form-data'
        )
>       assert rv.status_code == 200
E       assert 422 == 200
E         +422
E         -200

tests/test_fields.py:54: AssertionError

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can skip this test based on the version of flask-marshmallow. Example:

@pytest.mark.skipif(flask_sqlalchemy.__version__ < '3',

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flask_marshmallow has no attribute __version__. I'll make a pr for it.

AttributeError: module 'flask_marshmallow' has no attribute '__version__'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use importlib.metadata:

>>> from importlib.metadata import version
>>> version('flask')
'2.3.3'
>>> version('flask-marshmallow')
'0.15.0'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, could you help update the reference of flask_sqlalchemy.__version__ and change to use importlib.metadata.version?

That variable is deprecated.

@greyli greyli changed the title pin flask-marshmallow==1.2.1 and add tests Update dependencies and add tests for empty file field Mar 24, 2024
@greyli
Copy link
Member

greyli commented Mar 27, 2024

Why did you revert the changes to the requirement files? It's fine to update them (except the min-versions.*).

@uncle-lv
Copy link
Member Author

Why did you revert the changes to the requirement files? It's fine to update them (except the min-versions.*).

Because in the end no dependencies are updated.

@greyli greyli merged commit 664ad64 into apiflask:main Mar 28, 2024
16 checks passed
@uncle-lv uncle-lv deleted the pin-flask-marshmallow branch March 30, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants