apiflask / apiflask

A lightweight Python web API framework.
https://apiflask.com
MIT License
1.04k stars 129 forks source link

Fix warnings in the tests #594

Closed greyli closed 3 months ago

greyli commented 3 months ago
=================================================================================================== warnings summary ====================================================================================================
examples/test_examples.py:49
  /home/greyli/apiflask/examples/test_examples.py:49: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask-SQLAlchemy 3.2. Use feature detection or 'importlib.metadata.version("flask-sqlalchemy")' instead.
    flask_sqlalchemy.__version__ < '3', reason='Need flask_sqlalchemy 3 for get_or_404'

examples/test_examples.py:119
  /home/greyli/apiflask/examples/test_examples.py:119: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask-SQLAlchemy 3.2. Use feature detection or 'importlib.metadata.version("flask-sqlalchemy")' instead.
    flask_sqlalchemy.__version__ < '3', reason='Need flask_sqlalchemy 3 for get_or_404'

examples/test_examples.py:154
  /home/greyli/apiflask/examples/test_examples.py:154: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask-SQLAlchemy 3.2. Use feature detection or 'importlib.metadata.version("flask-sqlalchemy")' instead.
    flask_sqlalchemy.__version__ < '3', reason='Need flask_sqlalchemy 3 for get_or_404'

examples/test_examples.py:171
  /home/greyli/apiflask/examples/test_examples.py:171: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask-SQLAlchemy 3.2. Use feature detection or 'importlib.metadata.version("flask-sqlalchemy")' instead.
    flask_sqlalchemy.__version__ < '3', reason='Need flask_sqlalchemy 3 for paginate'

examples/test_examples.py:203
  /home/greyli/apiflask/examples/test_examples.py:203: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask-SQLAlchemy 3.2. Use feature detection or 'importlib.metadata.version("flask-sqlalchemy")' instead.
    flask_sqlalchemy.__version__ < '3', reason='Need flask_sqlalchemy 3 for paginate'

tests/test_app.py: 1 warning
tests/test_async.py: 2 warnings
tests/test_base_response.py: 6 warnings
tests/test_blueprint.py: 2 warnings
tests/test_decorator_auth_required.py: 4 warnings
tests/test_decorator_doc.py: 14 warnings
tests/test_decorator_input.py: 8 warnings
tests/test_decorator_output.py: 6 warnings
tests/test_openapi_basic.py: 6 warnings
tests/test_openapi_extensions.py: 1 warning
tests/test_openapi_info.py: 3 warnings
tests/test_openapi_paths.py: 8 warnings
tests/test_openapi_security.py: 6 warnings
tests/test_openapi_tags.py: 10 warnings
tests/test_route.py: 10 warnings
tests/test_schemas.py: 2 warnings
tests/test_security.py: 2 warnings
tests/test_settings_auto_behaviour.py: 23 warnings
tests/test_settings_openapi_fields.py: 4 warnings
tests/test_settings_response_customization.py: 9 warnings
  /home/greyli/apiflask/venv/lib/python3.10/site-packages/openapi_spec_validator/shortcuts.py:66: DeprecationWarning: validate_spec shortcut is deprecated. Use validate instead.
    warnings.warn(

examples/test_examples.py: 12 warnings
  /home/greyli/apiflask/venv/lib/python3.10/site-packages/marshmallow_dataclass/__init__.py:862: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'example': 'Medor', 'description': 'This will be printed in the generated doc. The "example" value "Medor" will be fed into the "try it"/"Send API request".'}
    return field(**metadata)
kulgan commented 3 months ago
examples/test_examples.py: 12 warnings
  /home/greyli/apiflask/venv/lib/python3.10/site-packages/marshmallow_dataclass/__init__.py:862: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'example': 'Medor', 'description': 'This will be printed in the generated doc. The "example" value "Medor" will be fed into the "try it"/"Send API request".'}
    return field(**metadata)

This warning is coming from marshmellow-dataclass

greyli commented 3 months ago

Thanks for working on this issue!

To fix the warning from marshmallow_dataclass, you will need to move this description field to a nested metadata field.

And there are some warnings from openapi_spec_validator, please handle them as well:

  /home/runner/work/apiflask/apiflask/.tox/py312/lib/python3.12/site-packages/openapi_spec_validator/shortcuts.py:66: DeprecationWarning: validate_spec shortcut is deprecated. Use validate instead.
    warnings.warn(