Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#151)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
pre-commit-ci[bot] and lafrech authored Jul 3, 2024
1 parent 8d60f4e commit 1db8ed9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.5.0
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -10,12 +10,12 @@ repos:
- id: check-github-workflows
- id: check-readthedocs
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.12.1]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.10.1
hooks:
- id: mypy
files: ^src/apispec_webframeworks/
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ include = ["tests/", "CHANGELOG.rst", "tox.ini"]
src = ["src"]
fix = true
show-fixes = true
show-source = true
output-format = "full"

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
select = [
Expand Down
7 changes: 4 additions & 3 deletions src/apispec_webframeworks/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from apispec import APISpec
from pprint import pprint
async def hello(request):
'''Get a greeting endpoint.
---
Expand All @@ -22,7 +23,7 @@ async def hello(request):
app = web.Application()
app.add_routes([web.get('/hello', hello)])
app.add_routes([web.get("/hello", hello)])
# Add all aiohttp routes to the APISpec
for route in app.router.routes():
Expand All @@ -34,8 +35,8 @@ async def hello(request):
route=route,
)
pprint(spec.to_dict()['paths'])
#{'/hello': {'get': {'description': 'Get a greeting',
pprint(spec.to_dict()["paths"])
# {'/hello': {'get': {'description': 'Get a greeting',
# 'responses': {'200': {'content': {'text/plain': {'schema': {'$ref': '#/definitions/Greeting'}}},
# 'description': 'A greeting to the '
# 'client'}}}}}
Expand Down
10 changes: 7 additions & 3 deletions src/apispec_webframeworks/bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
::
from bottle import route, default_app
app = default_app()
@route('/gists/<gist_id>')
@route("/gists/<gist_id>")
def gist_detail(gist_id):
'''Gist detail view.
---
Expand All @@ -14,10 +17,11 @@ def gist_detail(gist_id):
schema:
$ref: '#/definitions/Gist'
'''
return 'detail for gist {}'.format(gist_id)
return "detail for gist {}".format(gist_id)
spec.path(view=gist_detail)
print(spec.to_dict()['paths'])
print(spec.to_dict()["paths"])
# {'/gists/{gist_id}': {'get': {'responses': {200: {'schema': {'$ref': '#/definitions/Gist'}}}}}}
""" # noqa: E501

Expand Down
33 changes: 19 additions & 14 deletions src/apispec_webframeworks/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
app = Flask(__name__)
@app.route('/gists/<gist_id>')
@app.route("/gists/<gist_id>")
def gist_detail(gist_id):
'''Gist detail view.
---
Expand All @@ -18,11 +19,12 @@ def gist_detail(gist_id):
schema:
$ref: '#/definitions/Gist'
'''
return 'detail for gist {}'.format(gist_id)
return "detail for gist {}".format(gist_id)
with app.test_request_context():
spec.path(view=gist_detail)
print(spec.to_dict()['paths'])
print(spec.to_dict()["paths"])
# {'/gists/{gist_id}': {'get': {'responses': {200: {'schema': {'$ref': '#/definitions/Gist'}}}},
# 'x-extension': 'metadata'}}
Expand All @@ -33,33 +35,36 @@ def gist_detail(gist_id):
app = Flask(__name__)
class GistApi(MethodView):
'''Gist API.
---
x-extension: metadata
'''
def get(self):
'''Gist view
---
responses:
200:
schema:
$ref: '#/definitions/Gist'
'''
pass
'''Gist view
---
responses:
200:
schema:
$ref: '#/definitions/Gist'
'''
pass
def post(self):
pass
pass
method_view = GistApi.as_view('gists')
method_view = GistApi.as_view("gists")
app.add_url_rule("/gists", view_func=method_view)
with app.test_request_context():
spec.path(view=method_view)
# Alternatively, pass in an app object as a kwarg
# spec.path(view=method_view, app=app)
print(spec.to_dict()['paths'])
print(spec.to_dict()["paths"])
# {'/gists': {'get': {'responses': {200: {'schema': {'$ref': '#/definitions/Gist'}}}},
# 'post': {},
# 'x-extension': 'metadata'}}
Expand Down
6 changes: 4 additions & 2 deletions src/apispec_webframeworks/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tornado.web import RequestHandler
class HelloHandler(RequestHandler):
def get(self):
'''Get a greeting endpoint.
Expand All @@ -19,9 +20,10 @@ def get(self):
'''
self.write("hello")
urlspec = (r'/hello', HelloHandler)
urlspec = (r"/hello", HelloHandler)
spec.path(urlspec=urlspec)
pprint(spec.to_dict()['paths'])
pprint(spec.to_dict()["paths"])
# {'/hello': {'get': {'description': 'Get a greeting',
# 'responses': {200: {'description': 'A greeting to the '
# 'client',
Expand Down

0 comments on commit 1db8ed9

Please sign in to comment.