Skip to content

Commit

Permalink
Run pre-commit on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Jun 21, 2021
1 parent 749989d commit 6b76563
Show file tree
Hide file tree
Showing 37 changed files with 85 additions and 85 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Support using async error processor and async spec processor
([pull #57][pull_57]).
- Fix auto-tag support for nesting blueprint ([pull #58][pull_58]).
- Support set the url prefix of the OpenAPI blueprint with the
- Support set the url prefix of the OpenAPI blueprint with the
`openapi_blueprint_url_prefix` argument ([pull #64][pull_64]).
- Add `flask spec` command to output the OpenAPI spec to stdout
or a file, also add new config `LOCAL_SPEC_PATH` and
Expand Down Expand Up @@ -251,7 +251,7 @@ Released: 2021-3-27

Released: 2021-1-27

- Add view functions without response schema into spec ([commit](https://github.com/greyli/apiflask/commit/aabf427590227001e0e443d8d6a3bf5f56dc5964))
- Add view functions without response schema into spec ([commit](https://github.com/greyli/apiflask/commit/aabf427590227001e0e443d8d6a3bf5f56dc5964))
- Set default response descriptions ([commit](https://github.com/greyli/apiflask/commit/b9edf9e8f5731a8f45b359f6a101b4d39ba3f2f5))
- Stop rely on Flask-Marshmallow ([commit](https://github.com/greyli/apiflask/commit/cce7a0b8b97f345e087973b127c6d25c884dbc8f))
- Change default spec path to `openapi.json` ([commit](https://github.com/greyli/apiflask/commit/09d0d278a1fc27fa5868ef5848f3931bd8f76ef4))
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the "Q&A" category.
Include the following information in your post:

- Describe what you expected to happen.
- If possible, include a [minimal reproducible example][_mcve] to help us
- If possible, include a [minimal reproducible example][_mcve] to help us
identify the issue. This also helps check that the issue is not with
your own code.
- Describe what actually happened. Include the full traceback if there
Expand All @@ -40,7 +40,7 @@ issue on our [issue tracker][_gh_issue].
Include the following information in your post:

- Describe what you expected to happen.
- If possible, include a [minimal reproducible example][_mcve] to help us
- If possible, include a [minimal reproducible example][_mcve] to help us
identify the issue. This also helps check that the issue is not with
your own code.
- Describe what actually happened. Include the full traceback if there
Expand Down
2 changes: 1 addition & 1 deletion docs/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Or with npm:

!!! tip

The resources of Swagger UI can be found at the `dist` folder of release assets at
The resources of Swagger UI can be found at the `dist` folder of release assets at
[Swagger UI releases page][_swagger_ui_releases]{target=_blank}.

[_swagger_ui_releases]: https://github.com/swagger-api/swagger-ui/releases
2 changes: 1 addition & 1 deletion docs/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ See the following two sections for more details.

### A natural order of view arguments

By acting as a framework on top of Flask, APIFlask can overwrite the way Flask
By acting as a framework on top of Flask, APIFlask can overwrite the way Flask
passes path arguments to view functions from keyword arguments to positional
arguments.

Expand Down
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Here is a simple example for basic operates:
from apiflask import APIFlask

app = APIFlask(__name__)

# set a config
app.config['DESCRIPTION'] = 'A wonderful API'

Expand Down Expand Up @@ -548,7 +548,7 @@ app.config['AUTO_200_RESPONSE'] = False
If a view function uses `@input` to validate input request data, APIFlask will add a
validation error response into OpenAPI spec for this view. Set this config to `False`
to disable this behavior.

- Type: `bool`
- Default value: `True`
- Examples:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--8<-- 'examples/README.md'
--8<-- 'examples/README.md'
6 changes: 3 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def index():
return {'message': 'hello'}
```

The default title and version of the API will be `APIFlask` and `0.1.0`; you can
The default title and version of the API will be `APIFlask` and `0.1.0`; you can
pass the `title` and the `version` arguments to change these settings:

```python
Expand Down Expand Up @@ -619,7 +619,7 @@ status code with the `status_code` argument:
@input(PetInSchema)
@output(PetOutSchema, status_code=201)
def create_pet(data)
data['id'] = 2
data['id'] = 2
return data
```

Expand Down Expand Up @@ -657,7 +657,7 @@ def delete_pet(pet_id):
add more alternative responses for a view in the OpenAPI spec, you can
use the `@doc` decorator and pass a list to the `responses` parameter.
For example:

```python hl_lines="4"
@app.put('/pets/<int:pet_id>')
@input(PetInSchema)
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ per-file-ignores =
src/apiflask/fields.py: F401
src/apiflask/validators.py: F401
# HTML templates
src/apiflask/ui_templates.py: B950
src/apiflask/ui_templates.py: E501, B950
exclude =
# only used when running flake8 manually
.*
*.txt
*.md
__pycache__

[mypy]
Expand Down
10 changes: 5 additions & 5 deletions src/apiflask/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from marshmallow import pre_load as before_load
from marshmallow import post_dump as after_dump
from marshmallow import post_load as after_load
from marshmallow import pre_dump as before_dump
from marshmallow import post_dump as after_dump
from marshmallow import pre_load as before_load
from marshmallow import validates as validate
from marshmallow import validates_schema as validate_schema
from marshmallow import ValidationError as ValidationError
Expand All @@ -16,11 +16,11 @@
from .decorators import output as output
from .exceptions import abort as abort
from .exceptions import HTTPError as HTTPError
from .schemas import Schema as Schema
from .helpers import get_reason_phrase as get_reason_phrase
from .helpers import pagination_builder as pagination_builder
from .schemas import PaginationSchema as PaginationSchema
from .schemas import Schema as Schema
from .security import HTTPBasicAuth as HTTPBasicAuth
from .security import HTTPTokenAuth as HTTPTokenAuth
from .helpers import get_reason_phrase as get_reason_phrase
from .helpers import pagination_builder as pagination_builder

__version__ = '0.6.4dev'
8 changes: 4 additions & 4 deletions src/apiflask/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import typing as t
import json
import re
import sys
import typing as t
import warnings
import json

# temp fix for https://github.com/django/asgiref/issues/143
if sys.platform == 'win32' and (3, 8, 0) <= sys.version_info < (3, 9, 0): # pragma: no cover
Expand Down Expand Up @@ -243,7 +243,7 @@ def __init__(
- Add `openapi_blueprint_url_prefix` argument.
"""
super(APIFlask, self).__init__(
super().__init__(
import_name,
static_url_path=static_url_path,
static_folder=static_folder,
Expand Down Expand Up @@ -917,7 +917,7 @@ def _update_auth_info(auth: HTTPAuthType) -> None:
argument = get_argument(argument_type, argument_name)
arguments.append(argument)

for method, operation in operations.items():
for _method, operation in operations.items():
operation['parameters'] = arguments + operation['parameters']

path: str = re.sub(r'<([^<:]+:)?', '{', rule.rule).replace('>', '}')
Expand Down
4 changes: 2 additions & 2 deletions src/apiflask/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from flask import Blueprint

from .helpers import _sentinel
from .route import route_patch
from .route import route_shortcuts
from .helpers import _sentinel


@route_patch
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(
Other keyword arguments are directly passed to `flask.Blueprint`.
"""
super(APIBlueprint, self).__init__(
super().__init__(
name,
import_name,
static_folder=static_folder,
Expand Down
2 changes: 1 addition & 1 deletion src/apiflask/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from webargs.flaskparser import FlaskParser as BaseFlaskParser

from .exceptions import _ValidationError
from .helpers import _sentinel
from .schemas import EmptySchema
from .schemas import Schema
from .types import DecoratedType
Expand All @@ -17,7 +18,6 @@
from .types import RequestType
from .types import ResponseType
from .types import SchemaType
from .helpers import _sentinel


class FlaskParser(BaseFlaskParser):
Expand Down
2 changes: 1 addition & 1 deletion src/apiflask/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
documentation URL, etc.
headers: A dict of headers used in the error response.
"""
super(HTTPError, self).__init__()
super().__init__()
if status_code not in default_exceptions:
raise LookupError(
f'No exception for status code "{status_code}",'
Expand Down
1 change: 1 addition & 0 deletions src/apiflask/openapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

import typing as t

from apispec import APISpec
Expand Down
2 changes: 1 addition & 1 deletion src/apiflask/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from flask.views import MethodViewType

from .openapi import get_path_summary
from .openapi import get_path_description
from .openapi import get_path_summary


def route_patch(cls):
Expand Down
4 changes: 2 additions & 2 deletions src/apiflask/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
a scope of protection, defaults to use `'Authentication Required'`.
description: The description of the security scheme.
"""
super(HTTPBasicAuth, self).__init__(description=description)
super().__init__(description=description)
BaseHTTPBasicAuth.__init__(self, scheme=scheme, realm=realm)
self.error_handler(handle_auth_error)

Expand Down Expand Up @@ -109,6 +109,6 @@ def __init__(
description: The description of the security scheme.
"""
super(HTTPTokenAuth, self).__init__(description=description)
super().__init__(description=description)
BaseHTTPTokenAuth.__init__(self, scheme=scheme, realm=realm, header=header)
self.error_handler(handle_auth_error)
2 changes: 1 addition & 1 deletion src/apiflask/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import typing as t
import sys
import typing as t

if sys.version_info >= (3, 8):
from typing import Protocol
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

import pytest

from apiflask import APIFlask
Expand Down
3 changes: 2 additions & 1 deletion tests/schemas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from marshmallow import EXCLUDE

from apiflask import Schema
from apiflask.fields import Integer
from apiflask.fields import String
from marshmallow import EXCLUDE


class FooSchema(Schema):
Expand Down
11 changes: 5 additions & 6 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from openapi_spec_validator import validate_spec
from flask.views import MethodView
from flask import Blueprint
from flask.views import MethodView
from openapi_spec_validator import validate_spec

from apiflask import APIFlask
from .schemas import FooSchema
from .schemas import PaginationSchema
from apiflask import APIBlueprint
from apiflask import APIFlask
from apiflask import input
from apiflask import Schema
from apiflask.fields import Integer
from apiflask.fields import String

from .schemas import FooSchema
from .schemas import PaginationSchema


def test_app_init(app):
assert app
Expand Down
5 changes: 2 additions & 3 deletions tests/test_async.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
from openapi_spec_validator import validate_spec

from apiflask import output

from .schemas import FooSchema
from apiflask import output


def skip_flask1(app):
Expand Down Expand Up @@ -67,4 +66,4 @@ async def update_spec(spec):
rv = client.get('/openapi.json')
assert rv.status_code == 200
validate_spec(rv.json)
rv.json['info']['title'] == 'Updated Title'
assert rv.json['info']['title'] == 'Updated Title'
2 changes: 1 addition & 1 deletion tests/test_blueprint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from openapi_spec_validator import validate_spec
from flask.views import MethodView
from openapi_spec_validator import validate_spec

from apiflask import APIBlueprint
from apiflask import auth_required
Expand Down
1 change: 1 addition & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

import pytest

from apiflask.commands import spec_command


Expand Down
7 changes: 3 additions & 4 deletions tests/test_decorator_doc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from openapi_spec_validator import validate_spec
from flask.views import MethodView
from openapi_spec_validator import validate_spec

from .schemas import FooSchema
from apiflask import doc
from apiflask import input
from apiflask import output
from apiflask import doc

from .schemas import FooSchema


def test_doc_summary_and_description(app, client):
Expand Down
9 changes: 4 additions & 5 deletions tests/test_decorator_input.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import pytest
from openapi_spec_validator import validate_spec
from flask.views import MethodView
from openapi_spec_validator import validate_spec

from apiflask import input
from apiflask.fields import String

from .schemas import FooSchema
from .schemas import BarSchema
from .schemas import FooSchema
from .schemas import QuerySchema
from apiflask import input
from apiflask.fields import String


def test_input(app, client):
Expand Down
5 changes: 2 additions & 3 deletions tests/test_decorator_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
from flask.views import MethodView
from openapi_spec_validator import validate_spec

from .schemas import FooSchema
from .schemas import QuerySchema
from apiflask import input
from apiflask import output
from apiflask.fields import String

from .schemas import FooSchema
from .schemas import QuerySchema


def test_output(app, client):
@app.route('/foo')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from apiflask.exceptions import _default_error_handler
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
from apiflask.exceptions import _default_error_handler


@pytest.mark.parametrize('kwargs', [
Expand Down
Loading

0 comments on commit 6b76563

Please sign in to comment.