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

[pre-commit.ci] pre-commit autoupdate #151

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

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

oh nice! does this mean we can remove blacken-docs from pre-commit? 🤔

Copy link
Member

@lafrech lafrech Jul 2, 2024

Choose a reason for hiding this comment

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

I don't know. There seems to be a difference between

I didn't take the time to read those threads and wonder if the latter would be enough for our needs.

I picked this line from marshmallow's pyproject.toml without much thinking, TBH.

Copy link
Member

Choose a reason for hiding this comment

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

ah woops i didn't realize this was already in marshmallow. looks like formatting RST docs isn't implemented yet, so we still need blacken-docs for now


[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
Loading