Add #noqa and #TODOs
This commit is contained in:
@ -47,7 +47,7 @@ from reader import (
|
|||||||
TagNotFoundError,
|
TagNotFoundError,
|
||||||
)
|
)
|
||||||
from starlette.responses import RedirectResponse
|
from starlette.responses import RedirectResponse
|
||||||
from starlette.templating import _TemplateResponse
|
from starlette.templating import _TemplateResponse # noqa
|
||||||
|
|
||||||
from discord_rss_bot.feeds import send_to_discord
|
from discord_rss_bot.feeds import send_to_discord
|
||||||
from discord_rss_bot.search import create_html_for_search_results
|
from discord_rss_bot.search import create_html_for_search_results
|
||||||
@ -119,7 +119,6 @@ async def delete_webhook(webhook_url: str = Form()) -> RedirectResponse | dict[s
|
|||||||
Delete a webhook from the database.
|
Delete a webhook from the database.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
webhook_name: The name of the webhook.
|
|
||||||
webhook_url: The url of the webhook.
|
webhook_url: The url of the webhook.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -168,13 +167,14 @@ async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()) ->
|
|||||||
# Mark every entry as read, so we don't send all the old entries to Discord.
|
# Mark every entry as read, so we don't send all the old entries to Discord.
|
||||||
entries: Iterable[Entry] = reader.get_entries(feed=clean_feed_url, read=False)
|
entries: Iterable[Entry] = reader.get_entries(feed=clean_feed_url, read=False)
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
reader.set_entry_read(entry, True)
|
reader.set_entry_read(entry, True) # type: ignore
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hooks = reader.get_tag((), "webhooks")
|
hooks = reader.get_tag((), "webhooks")
|
||||||
except TagNotFoundError:
|
except TagNotFoundError:
|
||||||
hooks = []
|
hooks = []
|
||||||
|
|
||||||
|
webhook_url = None
|
||||||
if len(hooks) > 0:
|
if len(hooks) > 0:
|
||||||
# Get the webhook URL from the dropdown.
|
# Get the webhook URL from the dropdown.
|
||||||
for hook in hooks:
|
for hook in hooks:
|
||||||
@ -182,8 +182,13 @@ async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()) ->
|
|||||||
webhook_url = hook["url"]
|
webhook_url = hook["url"]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
# TODO: Show this error on the page.
|
||||||
return {"error": "Webhook not found."}
|
return {"error": "Webhook not found."}
|
||||||
|
|
||||||
|
if webhook_url is None:
|
||||||
|
# TODO: Show this error on the page.
|
||||||
|
return {"error": "No webhook URL found."}
|
||||||
|
|
||||||
reader.set_tag(clean_feed_url, "webhook", webhook_url) # type: ignore
|
reader.set_tag(clean_feed_url, "webhook", webhook_url) # type: ignore
|
||||||
reader.get_tag(clean_feed_url, "webhook")
|
reader.get_tag(clean_feed_url, "webhook")
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def test_send_to_discord() -> None:
|
|||||||
|
|
||||||
# Add tag to the feed and check if it is there.
|
# Add tag to the feed and check if it is there.
|
||||||
reader.set_tag(feed, "webhook", webhook_url) # type: ignore
|
reader.set_tag(feed, "webhook", webhook_url) # type: ignore
|
||||||
assert reader.get_tag(feed, "webhook") == webhook_url
|
assert reader.get_tag(feed, "webhook") == webhook_url # type: ignore
|
||||||
|
|
||||||
# Send the feed to Discord.
|
# Send the feed to Discord.
|
||||||
send_to_discord(custom_reader=reader, feed=feed, do_once=True)
|
send_to_discord(custom_reader=reader, feed=feed, do_once=True)
|
||||||
|
@ -35,7 +35,7 @@ def test_create_html_for_search_results() -> None:
|
|||||||
reader.update_search()
|
reader.update_search()
|
||||||
|
|
||||||
# Get the HTML for the search results.
|
# Get the HTML for the search results.
|
||||||
search_results: Iterable[EntrySearchResult] = reader.search_entries("a", feed=feed)
|
search_results: Iterable[EntrySearchResult] = reader.search_entries("a", feed=feed) # type: ignore
|
||||||
|
|
||||||
# Create the HTML and check if it is not empty.
|
# Create the HTML and check if it is not empty.
|
||||||
search_html: str = create_html_for_search_results(search_results, reader)
|
search_html: str = create_html_for_search_results(search_results, reader)
|
||||||
|
Reference in New Issue
Block a user