Skip to content

Commit 1db8ed9

Browse files
[pre-commit.ci] pre-commit autoupdate (#151)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](astral-sh/ruff-pre-commit@v0.4.10...v0.5.0) - [github.com/asottile/blacken-docs: 1.16.0 → 1.18.0](adamchainz/blacken-docs@1.16.0...1.18.0) - [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](pre-commit/mirrors-mypy@v1.10.0...v1.10.1) * Update ruff config --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jérôme Lafréchoux <jlafrechoux@nobatek.inef4.com>
1 parent 8d60f4e commit 1db8ed9

6 files changed

Lines changed: 41 additions & 26 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.4.10
3+
rev: v0.5.0
44
hooks:
55
- id: ruff
66
- id: ruff-format
@@ -10,12 +10,12 @@ repos:
1010
- id: check-github-workflows
1111
- id: check-readthedocs
1212
- repo: https://github.com/asottile/blacken-docs
13-
rev: 1.16.0
13+
rev: 1.18.0
1414
hooks:
1515
- id: blacken-docs
1616
additional_dependencies: [black==23.12.1]
1717
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v1.10.0
18+
rev: v1.10.1
1919
hooks:
2020
- id: mypy
2121
files: ^src/apispec_webframeworks/

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ include = ["tests/", "CHANGELOG.rst", "tox.ini"]
4545
src = ["src"]
4646
fix = true
4747
show-fixes = true
48-
show-source = true
48+
output-format = "full"
49+
50+
[tool.ruff.format]
51+
docstring-code-format = true
4952

5053
[tool.ruff.lint]
5154
select = [

src/apispec_webframeworks/aiohttp.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from apispec import APISpec
77
from pprint import pprint
88
9+
910
async def hello(request):
1011
'''Get a greeting endpoint.
1112
---
@@ -22,7 +23,7 @@ async def hello(request):
2223
2324
2425
app = web.Application()
25-
app.add_routes([web.get('/hello', hello)])
26+
app.add_routes([web.get("/hello", hello)])
2627
2728
# Add all aiohttp routes to the APISpec
2829
for route in app.router.routes():
@@ -34,8 +35,8 @@ async def hello(request):
3435
route=route,
3536
)
3637
37-
pprint(spec.to_dict()['paths'])
38-
#{'/hello': {'get': {'description': 'Get a greeting',
38+
pprint(spec.to_dict()["paths"])
39+
# {'/hello': {'get': {'description': 'Get a greeting',
3940
# 'responses': {'200': {'content': {'text/plain': {'schema': {'$ref': '#/definitions/Greeting'}}},
4041
# 'description': 'A greeting to the '
4142
# 'client'}}}}}

src/apispec_webframeworks/bottle.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
::
44
55
from bottle import route, default_app
6+
67
app = default_app()
7-
@route('/gists/<gist_id>')
8+
9+
10+
@route("/gists/<gist_id>")
811
def gist_detail(gist_id):
912
'''Gist detail view.
1013
---
@@ -14,10 +17,11 @@ def gist_detail(gist_id):
1417
schema:
1518
$ref: '#/definitions/Gist'
1619
'''
17-
return 'detail for gist {}'.format(gist_id)
20+
return "detail for gist {}".format(gist_id)
21+
1822
1923
spec.path(view=gist_detail)
20-
print(spec.to_dict()['paths'])
24+
print(spec.to_dict()["paths"])
2125
# {'/gists/{gist_id}': {'get': {'responses': {200: {'schema': {'$ref': '#/definitions/Gist'}}}}}}
2226
""" # noqa: E501
2327

src/apispec_webframeworks/flask.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
88
app = Flask(__name__)
99
10-
@app.route('/gists/<gist_id>')
10+
11+
@app.route("/gists/<gist_id>")
1112
def gist_detail(gist_id):
1213
'''Gist detail view.
1314
---
@@ -18,11 +19,12 @@ def gist_detail(gist_id):
1819
schema:
1920
$ref: '#/definitions/Gist'
2021
'''
21-
return 'detail for gist {}'.format(gist_id)
22+
return "detail for gist {}".format(gist_id)
23+
2224
2325
with app.test_request_context():
2426
spec.path(view=gist_detail)
25-
print(spec.to_dict()['paths'])
27+
print(spec.to_dict()["paths"])
2628
# {'/gists/{gist_id}': {'get': {'responses': {200: {'schema': {'$ref': '#/definitions/Gist'}}}},
2729
# 'x-extension': 'metadata'}}
2830
@@ -33,33 +35,36 @@ def gist_detail(gist_id):
3335
3436
app = Flask(__name__)
3537
38+
3639
class GistApi(MethodView):
3740
'''Gist API.
3841
---
3942
x-extension: metadata
4043
'''
44+
4145
def get(self):
42-
'''Gist view
43-
---
44-
responses:
45-
200:
46-
schema:
47-
$ref: '#/definitions/Gist'
48-
'''
49-
pass
46+
'''Gist view
47+
---
48+
responses:
49+
200:
50+
schema:
51+
$ref: '#/definitions/Gist'
52+
'''
53+
pass
5054
5155
def post(self):
52-
pass
56+
pass
57+
5358
54-
method_view = GistApi.as_view('gists')
59+
method_view = GistApi.as_view("gists")
5560
app.add_url_rule("/gists", view_func=method_view)
5661
with app.test_request_context():
5762
spec.path(view=method_view)
5863
5964
# Alternatively, pass in an app object as a kwarg
6065
# spec.path(view=method_view, app=app)
6166
62-
print(spec.to_dict()['paths'])
67+
print(spec.to_dict()["paths"])
6368
# {'/gists': {'get': {'responses': {200: {'schema': {'$ref': '#/definitions/Gist'}}}},
6469
# 'post': {},
6570
# 'x-extension': 'metadata'}}

src/apispec_webframeworks/tornado.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
from tornado.web import RequestHandler
88
9+
910
class HelloHandler(RequestHandler):
1011
def get(self):
1112
'''Get a greeting endpoint.
@@ -19,9 +20,10 @@ def get(self):
1920
'''
2021
self.write("hello")
2122
22-
urlspec = (r'/hello', HelloHandler)
23+
24+
urlspec = (r"/hello", HelloHandler)
2325
spec.path(urlspec=urlspec)
24-
pprint(spec.to_dict()['paths'])
26+
pprint(spec.to_dict()["paths"])
2527
# {'/hello': {'get': {'description': 'Get a greeting',
2628
# 'responses': {200: {'description': 'A greeting to the '
2729
# 'client',

0 commit comments

Comments
 (0)