Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Prune and narrow `# noqa` comments (#639)

Dhruv Bhanushalif2ff9ae525ae
diff --git a/DOCUMENTATION_GUIDELINES.md b/DOCUMENTATION_GUIDELINES.md
index 970599981..cec135790 100644
--- a/DOCUMENTATION_GUIDELINES.md
+++ b/DOCUMENTATION_GUIDELINES.md
@@ -63,7 +63,7 @@ image_stats_description = \
You can refer to Bash's Request Samples for example on how to use
this endpoint.
- """ # noqa
+ """
@swagger_auto_schema(operation_id='image_stats',
operation_description=image_stats_description)
@@ -168,7 +168,7 @@ image_stats_bash = \
"""
# Get a list of content providers and their image count
curl -H "Authorization: Bearer DLBYIcfnKfolaXKcmMC8RIDCavc2hW" http://api.openverse.engineering/v1/sources
- """ # noqa
+ """
@swagger_auto_schema(operation_id='image_stats',
operation_description=image_stats_description,
diff --git a/api/catalog/api/docs/audio_docs.py b/api/catalog/api/docs/audio_docs.py
index 6d89d07a1..79c00f68c 100644
--- a/api/catalog/api/docs/audio_docs.py
+++ b/api/catalog/api/docs/audio_docs.py
@@ -39,11 +39,11 @@ class AudioSearch(MediaSearch):
desc = f"""
audio_search is an API endpoint to search audio files using a query string.
-By using this endpoint, you can obtain search results based on specified
-query and optionally filter results by
+By using this endpoint, you can obtain search results based on specified query and
+optionally filter results by
{fields_to_md(AudioSearchRequestSerializer.fields_names)}.
-{MediaSearch.desc}""" # noqa
+{MediaSearch.desc}"""
responses = {
"200": openapi.Response(
@@ -79,7 +79,7 @@ class AudioStats(MediaStats):
audio_stats is an API endpoint to get a list of all content providers and their
respective number of audio files in the Openverse catalog.
-{MediaStats.desc}""" # noqa
+{MediaStats.desc}"""
responses = {
"200": openapi.Response(
@@ -111,7 +111,7 @@ audio_detail is an API endpoint to get the details of a specified audio ID.
By using this endpoint, you can get audio details such as
{fields_to_md(AudioSerializer.fields_names)}.
-{MediaDetail.desc}""" # noqa
+{MediaDetail.desc}"""
responses = {
"200": openapi.Response(
@@ -141,13 +141,13 @@ By using this endpoint, you can get audio details such as
class AudioRelated(MediaRelated):
desc = f"""
-recommendations_audio_read is an API endpoint to get related audio files
-for a specified audio ID.
+recommendations_audio_read is an API endpoint to get related audio files for a specified
+audio ID.
By using this endpoint, you can get the details of related audio such as
{fields_to_md(AudioSerializer.fields_names)}.
-{MediaRelated.desc}""" # noqa
+{MediaRelated.desc}"""
responses = {
"200": openapi.Response(
@@ -177,13 +177,13 @@ By using this endpoint, you can get the details of related audio such as
class AudioComplain(MediaComplain):
desc = f"""
-audio_report_create is an API endpoint to report an issue about a specified
-audio ID to Openverse.
+audio_report_create is an API endpoint to report an issue about a specified audio ID to
+Openverse.
-By using this endpoint, you can report an audio file if it infringes copyright,
-contains mature or sensitive content and others.
+By using this endpoint, you can report an audio file if it infringes copyright, contains
+mature or sensitive content and others.
-{MediaComplain.desc}""" # noqa
+{MediaComplain.desc}"""
responses = {
"201": openapi.Response(
diff --git a/api/catalog/api/docs/image_docs.py b/api/catalog/api/docs/image_docs.py
index 6bccc2d41..f5c5fac9f 100644
--- a/api/catalog/api/docs/image_docs.py
+++ b/api/catalog/api/docs/image_docs.py
@@ -45,11 +45,11 @@ class ImageSearch(MediaSearch):
desc = f"""
image_search is an API endpoint to search images using a query string.
-By using this endpoint, you can obtain search results based on specified query
-and optionally filter results by
+By using this endpoint, you can obtain search results based on specified query and
+optionally filter results by
{fields_to_md(ImageSearchRequestSerializer.fields_names)}.
-{MediaSearch.desc}""" # noqa
+{MediaSearch.desc}"""
responses = {
"200": openapi.Response(
@@ -85,7 +85,7 @@ class ImageStats(MediaStats):
image_stats is an API endpoint to get a list of all content providers and their
respective number of images in the Openverse catalog.
-{MediaStats.desc}""" # noqa
+{MediaStats.desc}"""
responses = {
"200": openapi.Response(
@@ -117,7 +117,7 @@ image_detail is an API endpoint to get the details of a specified image ID.
By using this endpoint, you can image details such as
{fields_to_md(ImageSerializer.fields_names)}.
-{MediaDetail.desc}""" # noqa
+{MediaDetail.desc}"""
responses = {
"200": openapi.Response(
@@ -142,13 +142,13 @@ By using this endpoint, you can image details such as
class ImageRelated(MediaRelated):
desc = f"""
-recommendations_images_read is an API endpoint to get related images
-for a specified image ID.
+recommendations_images_read is an API endpoint to get related images for a specified
+image ID.
By using this endpoint, you can get the details of related images such as
{fields_to_md(ImageSerializer.fields_names)}.
-{MediaRelated.desc}""" # noqa
+{MediaRelated.desc}"""
responses = {
"200": openapi.Response(
@@ -173,13 +173,13 @@ By using this endpoint, you can get the details of related images such as
class ImageComplain(MediaComplain):
desc = f"""
-images_report_create is an API endpoint to report an issue about a specified
-image ID to Openverse.
+images_report_create is an API endpoint to report an issue about a specified image ID to
+Openverse.
-By using this endpoint, you can report an image if it infringes copyright,
-contains mature or sensitive content and others.
+By using this endpoint, you can report an image if it infringes copyright, contains
+mature or sensitive content and others.
-{MediaComplain.desc}""" # noqa
+{MediaComplain.desc}"""
responses = {
"201": openapi.Response(
@@ -206,14 +206,12 @@ contains mature or sensitive content and others.
class ImageOembed:
desc = f"""
-oembed_list is an API endpoint to retrieve embedded content from a
-specified image URL.
+oembed_list is an API endpoint to retrieve embedded content from a specified image URL.
-By using this endpoint, you can retrieve embedded content such as `version`,
-`type`, `width`, `height`, `title`, `author_name`, `author_url` and
-`license_url`.
+By using this endpoint, you can retrieve embedded content such as `version`, `type`,
+`width`, `height`, `title`, `author_name`, `author_url` and `license_url`.
-{refer_sample}""" # noqa
+{refer_sample}"""
responses = {
"200": openapi.Response(
diff --git a/api/catalog/api/docs/media_docs.py b/api/catalog/api/docs/media_docs.py
index fcdc6683c..00f74d637 100644
--- a/api/catalog/api/docs/media_docs.py
+++ b/api/catalog/api/docs/media_docs.py
@@ -19,37 +19,32 @@ def fields_to_md(field_names):
class MediaSearch:
- desc = (
- """
-Results are ranked in order of relevance and paginated on the basis of the
-`page` param. The `page_size` param controls the total number of pages.
-
-Although there may be millions of relevant records, only the most
-relevant several thousand records can be viewed. This is by design:
-the search endpoint should be used to find the top 10,000 most relevant
-results, not for exhaustive search or bulk download of every barely
-relevant result. As such, the caller should not try to access pages
-beyond `page_count`, or else the server will reject the query.
+ desc = f"""
+Results are ranked in order of relevance and paginated on the basis of the `page` param.
+The `page_size` param controls the total number of pages.
+
+Although there may be millions of relevant records, only the most relevant several
+thousand records can be viewed. This is by design: the search endpoint should be used to
+find the top 10,000 most relevant results, not for exhaustive search or bulk download of
+every barely relevant result. As such, the caller should not try to access pages beyond
+`page_count`, or else the server will reject the query.
For more precise results, you can go to the
[Openverse Syntax Guide](https://search.creativecommons.org/search-help)
for information about creating queries and
[Apache Lucene Syntax Guide](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
for information on structuring advanced searches.
-""" # noqa
- f"{refer_sample}"
- )
+
+{refer_sample}""" # noqa: E501
class MediaStats:
- desc = (
- """
-You can use this endpoint to get details about content providers such as
-`source_name`, `display_name`, and `source_url` along with a count of the number
-of individual items indexed from them.
-""" # noqa
- f"{refer_sample}"
- )
+ desc = f"""
+You can use this endpoint to get details about content providers such as `source_name`,
+`display_name`, and `source_url` along with a count of the number of individual items
+indexed from them.
+
+{refer_sample}"""
class MediaDetail:
@@ -61,10 +56,8 @@ class MediaRelated:
class MediaComplain:
- desc = (
- """
-By using this endpoint, you can report a file if it infringes copyright,
-contains mature or sensitive content and others.
-""" # noqa
- f"{refer_sample}"
- )
+ desc = f"""
+By using this endpoint, you can report a file if it infringes copyright, contains mature
+or sensitive content and others.
+
+{refer_sample}"""
diff --git a/api/catalog/api/examples/audio_requests.py b/api/catalog/api/examples/audio_requests.py
index f3661e4f5..5fab43653 100644
--- a/api/catalog/api/examples/audio_requests.py
+++ b/api/catalog/api/examples/audio_requests.py
@@ -23,29 +23,39 @@ syntax_examples = {
audio_search_list_curl = "\n".join(
f"""
# Example {index}: Search for audio {purpose}
-curl {auth} "{origin}/v1/audio/?q={syntax}"
+curl \\
+ {auth} \\
+ "{origin}/v1/audio/?q={syntax}"
"""
for (index, (purpose, syntax)) in enumerate(syntax_examples.items())
)
audio_search_curl = f"""
# Search for music titled "Wish You Were Here" by The.madpix.project
-curl {auth} "{origin}/v1/audio/?title=Wish%20You%20Were%20Here&creator=The.madpix.project"
-""" # noqa
+curl \\
+ {auth} \\
+ "{origin}/v1/audio/?title=Wish%20You%20Were%20Here&creator=The.madpix.project"
+"""
audio_stats_curl = f"""
# Get the statistics for audio sources
-curl {auth} "{origin}/v1/audio/stats/"
+curl \\
+ {auth} \\
+ "{origin}/v1/audio/stats/"
"""
audio_detail_curl = f"""
# Get the details of audio ID {identifier}
-curl {auth} "{origin}/v1/audio/{identifier}/"
+curl \\
+ {auth} \\
+ "{origin}/v1/audio/{identifier}/"
"""
audio_related_curl = f"""
# Get related audio files for audio ID {identifier}
-curl {auth} "{origin}/v1/audio/{identifier}/related/"
+curl \\
+ {auth} \\
+ "{origin}/v1/audio/{identifier}/related/"
"""
audio_complain_curl = f"""
@@ -56,4 +66,4 @@ curl \\
{auth} \\
-d '{{"reason": "mature", "description": "This audio contains sensitive content"}}' \\
"{origin}/v1/audio/{identifier}/report/"
-""" # noqa
+"""
diff --git a/api/catalog/api/examples/audio_responses.py b/api/catalog/api/examples/audio_responses.py
index dd02b11bc..a236aafef 100644
--- a/api/catalog/api/examples/audio_responses.py
+++ b/api/catalog/api/examples/audio_responses.py
@@ -54,7 +54,7 @@ audio_search_200_example = {
audio_search_400_example = {
"application/json": {
"error": "InputError",
- "detail": "Invalid input given for fields. 'license' -> License 'PDMNBCG' does not exist.", # noqa
+ "detail": "Invalid input given for fields. 'license' -> License 'PDMNBCG' does not exist.", # noqa: E501
"fields": ["license"],
}
}
@@ -81,10 +81,10 @@ audio_stats_200_example = {
audio_detail_200_example = {
"application/json": base_audio
| {
- "attribution": '"Wish You Were Here" by The.madpix.project is licensed under CC-BY-NC-SA 3.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/.', # noqa
+ "attribution": '"Wish You Were Here" by The.madpix.project is licensed under CC-BY-NC-SA 3.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/.', # noqa: E501
"audio_set": {
"title": "Wish You Were Here",
- "foreign_landing_url": "https://www.jamendo.com/album/145774/wish-you-were-here", # noqa
+ "foreign_landing_url": "https://www.jamendo.com/album/145774/wish-you-were-here", # noqa: E501
"creator": "The.madpix.project",
"creator_url": "https://www.jamendo.com/artist/441585/the.madpix.project",
"url": "https://usercontent.jamendo.com?type=album&id=145774&width=200",
@@ -108,19 +108,19 @@ audio_related_200_example = {
"page_count": 0,
"results": [
{
- "title": "File:Mozart - Eine kleine Nachtmusik - 1. Allegro.ogg", # noqa
+ "title": "File:Mozart - Eine kleine Nachtmusik - 1. Allegro.ogg",
"id": "36537842-b067-4ca0-ad67-e00ff2e06b2e",
"creator": "Wolfgang Amadeus Mozart",
- "creator_url": "https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart", # noqa
- "url": "https://upload.wikimedia.org/wikipedia/commons/2/24/Mozart_-_Eine_kleine_Nachtmusik_-_1._Allegro.ogg", # noqa
+ "creator_url": "https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart",
+ "url": "https://upload.wikimedia.org/wikipedia/commons/2/24/Mozart_-_Eine_kleine_Nachtmusik_-_1._Allegro.ogg", # noqa: E501
"provider": "wikimedia",
"source": "wikimedia",
"license": "by-sa",
"license_version": "2.0",
- "license_url": "https://creativecommons.org/licenses/by-sa/2.0/", # noqa
- "foreign_landing_url": "https://commons.wikimedia.org/w/index.php?curid=3536953", # noqa
- "detail_url": "http://api.openverse.engineering/v1/audio/36537842-b067-4ca0-ad67-e00ff2e06b2e", # noqa
- "related_url": "http://api.openverse.engineering/v1/recommendations/audio/36537842-b067-4ca0-ad67-e00ff2e06b2e", # noqa
+ "license_url": "https://creativecommons.org/licenses/by-sa/2.0/",
+ "foreign_landing_url": "https://commons.wikimedia.org/w/index.php?curid=3536953", # noqa: E501
+ "detail_url": "http://api.openverse.engineering/v1/audio/36537842-b067-4ca0-ad67-e00ff2e06b2e", # noqa: E501
+ "related_url": "http://api.openverse.engineering/v1/recommendations/audio/36537842-b067-4ca0-ad67-e00ff2e06b2e", # noqa: E501
"fields_matched": ["description", "title"],
"tags": [{"name": "exam"}, {"name": "tactics"}],
}
diff --git a/api/catalog/api/examples/image_requests.py b/api/catalog/api/examples/image_requests.py
index 0a1f09350..593318ce7 100644
--- a/api/catalog/api/examples/image_requests.py
+++ b/api/catalog/api/examples/image_requests.py
@@ -23,29 +23,39 @@ syntax_examples = {
image_search_list_curl = "\n".join(
f"""
# Example {index}: Search for images {purpose}
-curl {auth} "{origin}/v1/images/?q={syntax}"
+curl \\
+ {auth} \\
+ "{origin}/v1/images/?q={syntax}"
"""
for (index, (purpose, syntax)) in enumerate(syntax_examples.items())
)
image_search_curl = f"""
# Search for images titled "Bust" by Talbot
-curl {auth} "{origin}/v1/images/?title=Train&creator=Trolle"
+curl \\
+ {auth} \\
+ "{origin}/v1/images/?title=Train&creator=Trolle"
"""
image_stats_curl = f"""
# Get the statistics for image sources
-curl {auth} "{origin}/v1/images/stats/"
+curl \\
+ {auth} \\
+ "{origin}/v1/images/stats/"
"""
image_detail_curl = f"""
# Get the details of image ID {identifier}
-curl {auth} "{origin}/v1/images/{identifier}/"
+curl \\
+ {auth} \\
+ "{origin}/v1/images/{identifier}/"
"""
image_related_curl = f"""
# Get related images for image ID {identifier}
-curl {auth} "{origin}/v1/images/{identifier}/related/"
+curl \\
+ {auth} \\
+ "{origin}/v1/images/{identifier}/related/"
"""
image_complain_curl = f"""
@@ -54,11 +64,13 @@ curl \\
-X POST \\
-H "Content-Type: application/json" \\
{auth} \\
- -d '{{"reason": "mature", "description": "This image contains sensitive content"}}' \\
+ -d '{{"reason": "mature", "description": "Image contains sensitive content"}}' \\
"{origin}/v1/images/{identifier}/report/"
-""" # noqa
+"""
image_oembed_curl = f"""
-# Retrieve embedded content from image URL (https://wordpress.org/openverse/photos/{identifier})
-curl {auth} "{origin}/v1/images/oembed/?url=https://wordpress.org/openverse/photos/{identifier}"
-""" # noqa
+# Retrieve embedded content from an image's URL
+curl \\
+ {auth} \\
+ "{origin}/v1/images/oembed/?url=https://wordpress.org/openverse/photos/{identifier}"
+"""
diff --git a/api/catalog/api/examples/image_responses.py b/api/catalog/api/examples/image_responses.py
index 2f4fbb2e2..ba913f5cd 100644
--- a/api/catalog/api/examples/image_responses.py
+++ b/api/catalog/api/examples/image_responses.py
@@ -56,7 +56,7 @@ image_search_200_example = {
image_search_400_example = {
"application/json": {
"error": "InputError",
- "detail": "Invalid input given for fields. 'license' -> License 'PDMNBCG' does not exist.", # noqa
+ "detail": "Invalid input given for fields. 'license' -> License 'PDMNBCG' does not exist.", # noqa: E501
"fields": ["license"],
}
}
@@ -83,7 +83,7 @@ image_stats_200_example = {
image_detail_200_example = {
"application/json": base_image
| {
- "attribution": '"Train area in Copenhagen South / Tog område i Syd København" by Kristoffer Trolle is licensed under CC-BY 2.0. To view a copy of this license, visit https://creativecommons.org/licenses/by/2.0/.', # noqa
+ "attribution": '"Train area in Copenhagen South / Tog område i Syd København" by Kristoffer Trolle is licensed under CC-BY 2.0. To view a copy of this license, visit https://creativecommons.org/licenses/by/2.0/.', # noqa: E501
"height": 683,
"width": 1024,
"filesize": "157497",
@@ -104,16 +104,16 @@ image_related_200_example = {
"creator": "Sean MacEntee",
"creator_url": "https://www.flickr.com/photos/18090920@N07",
"tags": [{"name": "exam"}, {"name": "tactics"}],
- "url": "https://live.staticflickr.com/4065/4459771899_07595dc42e.jpg", # noqa
- "thumbnail": "https://api.openverse.engineering/v1/thumbs/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa
+ "url": "https://live.staticflickr.com/4065/4459771899_07595dc42e.jpg", # noqa: E501
+ "thumbnail": "https://api.openverse.engineering/v1/thumbs/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa: E501
"provider": "flickr",
"source": "flickr",
"license": "by",
"license_version": "2.0",
"license_url": "https://creativecommons.org/licenses/by/2.0/",
- "foreign_landing_url": "https://www.flickr.com/photos/18090920@N07/4459771899", # noqa
- "detail_url": "http://api.openverse.engineering/v1/images/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa
- "related_url": "http://api.openverse.engineering/v1/recommendations/images/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa
+ "foreign_landing_url": "https://www.flickr.com/photos/18090920@N07/4459771899", # noqa: E501
+ "detail_url": "http://api.openverse.engineering/v1/images/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa: E501
+ "related_url": "http://api.openverse.engineering/v1/recommendations/images/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa: E501
}
],
}
@@ -144,6 +144,6 @@ image_complain_201_example = {
"application/json": {
"identifier": identifier,
"reason": "mature",
- "description": "This image contains sensitive content",
+ "description": "Image contains sensitive content",
}
}
diff --git a/api/catalog/api/views/oauth2_views.py b/api/catalog/api/views/oauth2_views.py
index b5d45b318..d04ac18d0 100644
--- a/api/catalog/api/views/oauth2_views.py
+++ b/api/catalog/api/views/oauth2_views.py
@@ -2,6 +2,7 @@ import logging as log
import secrets
import smtplib
+from catalog.api.docs.media_docs import refer_sample
from catalog.api.models import OAuth2Verification, ThrottledApplication
from catalog.api.serializers.error_serializers import (
ForbiddenErrorSerializer,
@@ -33,24 +34,22 @@ from rest_framework.views import APIView
class Register(APIView):
swagger_schema = CustomAutoSchema
- register_api_oauth2_description = """
- register_api_oauth2 is an API endpoint to register access to the API via OAuth2.
-
- Upon registering, you will receive a `client_id` and `client_secret`,
- which you can then use to authenticate using the standard OAuth2 Client
- Credentials flow. See the Register and Authenticate section for instructions on registering access to the API via OAuth2.
- <br>
- <blockquote>
- <b>WARNING :</b> You must keep <code>client_secret</code> confidential,
- as anybody with your <code>client_secret</code> can impersonate your application.
- </blockquote>
-
- Authenticated users have higher rate limits than anonymous users.
- Additionally, by identifying yourself, you can request Openverse to
- adjust your personal rate limit depending on your organization's needs.
-
- You can also refer to Bash's Request Samples for examples on how to use this endpoint.
- """ # noqa
+ register_api_oauth2_description = f"""
+register_api_oauth2 is an API endpoint to register access to the API via OAuth2.
+
+Upon registering, you will receive a `client_id` and `client_secret`, which you can then
+use to authenticate using the standard OAuth2 Client Credentials flow. See the Register
+and Authenticate section for instructions on registering access to the API via OAuth2.
+
+> **WARNING:** You must keep `client_secret` confidential, as anybody with your
+> `client_secret` can impersonate your application.
+
+Authenticated users have higher rate limits than anonymous users. Additionally, by
+identifying yourself, you can request Openverse to adjust your personal rate limit
+depending on your organization's needs.
+
+{refer_sample}"""
+
throttle_classes = (TenPerDay,)
register_api_oauth2_response = {
"201": openapi.Response(
@@ -61,9 +60,13 @@ class Register(APIView):
}
register_api_oauth2_bash = """
- # Register for a key
- curl -X POST -H "Content-Type: application/json" -d '{"name": "My amazing project", "description": "To access Openverse API", "email": "[email protected]"}' https://api.openverse.engineering/v1/auth_tokens/register
- """ # noqa
+# Register for a key
+curl \\
+ -X POST \\
+ -H "Content-Type: application/json" \\
+ -d '{"name": "My amazing project", "description": "To access Openverse API", "email": "[email protected]"}' \\
+ https://api.openverse.engineering/v1/auth_tokens/register
+""" # noqa: E501
register_api_oauth2_request = openapi.Schema(
type=openapi.TYPE_OBJECT,
@@ -202,21 +205,16 @@ class VerifyEmail(APIView):
class CheckRates(APIView):
swagger_schema = CustomAutoSchema
- key_info_description = """
- key_info is an API endpoint to get information about your API key.
+ key_info_description = f"""
+key_info is an API endpoint to get information about your API key.
+
+You can use this endpoint to get information about your API key such as
+`requests_this_minute`, `requests_today`, and `rate_limit_model`.
- You can use this endpoint to get information about your API key such as
- requests_this_minute, requests_today, and rate_limit_model.
+> **NOTE:** If you get a 403 Forbidden response, it means your access token has expired.
- <blockquote>
- <b>NOTE :</b> If you get a 403 Forbidden response, it means your
- access token has expired.
- </blockquote>
+{refer_sample}"""
- <br>
- You can refer to Bash's Request Samples for example on how to use
- this endpoint.
- """ # noqa
throttle_classes = (OnePerSecond,)
key_info_response = {
@@ -236,9 +234,10 @@ class CheckRates(APIView):
}
key_info_bash = """
- # Get information about your API key
- curl -H "Authorization: Bearer DLBYIcfnKfolaXKcmMC8RIDCavc2hW" http://api.openverse.engineering/v1/rate_limit
- """ # noqa
+curl \\
+ -H "Authorization: Bearer DLBYIcfnKfolaXKcmMC8RIDCavc2hW" \\
+ http://api.openverse.engineering/v1/rate_limit
+"""
@swagger_auto_schema(
operation_id="key_info",
diff --git a/api/catalog/example_responses.py b/api/catalog/example_responses.py
index d1e078356..53bf84c5c 100644
--- a/api/catalog/example_responses.py
+++ b/api/catalog/example_responses.py
@@ -1,8 +1,13 @@
+client_secret = (
+ "YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOh"
+ "BUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e"
+)
+
register_api_oauth2_201_example = {
"application/json": {
"name": "My amazing project",
"client_id": "pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda",
- "client_secret": "YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOhBUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e", # noqa: E501
+ "client_secret": client_secret,
}
}
diff --git a/api/catalog/logger.py b/api/catalog/logger.py
index 023816f3a..0d7405b25 100644
--- a/api/catalog/logger.py
+++ b/api/catalog/logger.py
@@ -26,7 +26,7 @@ LOGGING = {
"style": "{",
},
"console": {
- "format": "[%(asctime)s - %(name)s - %(lineno)3d][%(levelname)s] %(message)s", # noqa
+ "format": "[%(asctime)s - %(name)s - %(lineno)3d][%(levelname)s] %(message)s", # noqa: E501
},
},
"handlers": {
diff --git a/api/catalog/settings.py b/api/catalog/settings.py
index 234cd6581..b2338789e 100644
--- a/api/catalog/settings.py
+++ b/api/catalog/settings.py
@@ -14,11 +14,10 @@ from pathlib import Path
from socket import gethostbyname, gethostname
import sentry_sdk
+from catalog.logger import LOGGING as LOGGING_CONF
from decouple import config
from sentry_sdk.integrations.django import DjangoIntegration
-from .logger import LOGGING # noqa: F401
-
# Build paths inside the project like this: BASE_DIR.join('dir', 'subdir'...)
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -69,6 +68,8 @@ SHORT_URL_PATH_WHITELIST = ["/v1/list", "/v1/images/"]
USE_S3 = config("USE_S3", default=False, cast=bool)
+LOGGING = LOGGING_CONF
+
# Application definition
INSTALLED_APPS = [
diff --git a/api/docs/conf.py b/api/docs/conf.py
index 188071b27..988315217 100644
--- a/api/docs/conf.py
+++ b/api/docs/conf.py
@@ -15,7 +15,7 @@ import django
sys.path.append(os.path.abspath(".."))
django.setup()
-from django.conf import settings # noqa: E402
+from django.conf import settings # noqa: E402 | Run ``setup`` before ``import``
# Project information
diff --git a/api/test/examples_test.py b/api/test/examples_test.py
index 025182c11..c297d007e 100644
--- a/api/test/examples_test.py
+++ b/api/test/examples_test.py
@@ -10,7 +10,7 @@ os.environ["AUDIO_REQ_TOKEN"] = ""
os.environ["AUDIO_REQ_ORIGIN"] = API_URL
os.environ["AUDIO_REQ_IDX"] = "8624ba61-57f1-4f98-8a85-ece206c319cf"
-from catalog.api.examples import ( # noqa | Set env vars before import
+from catalog.api.examples import ( # noqa: E402 | Set env vars before import
audio_mappings,
image_mappings,
)