Skip to content

Commit

Permalink
final ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
le717 committed Jun 8, 2024
1 parent dbdce77 commit 15648d1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
9 changes: 3 additions & 6 deletions db/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
config.set_main_option("sqlalchemy.url", db_uri)
target_metadata = db.metadata

# Configure anything else you deem important, example:
# my_important_option = config.get_main_option("my_important_option")


def run_migrations_offline():
def run_migrations_offline() -> None:
"""
Run migrations in 'offline' mode.
Expand All @@ -46,7 +43,7 @@ def run_migrations_offline():
context.run_migrations()


def run_migrations_online():
def run_migrations_online() -> None:
"""
Run migrations in 'online' mode.
Expand All @@ -57,7 +54,7 @@ def run_migrations_online():
# If you use Alembic revision's --autogenerate flag this function will
# prevent Alembic from creating an empty migration file if nothing changed.
# Source: https://alembic.sqlalchemy.org/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
def process_revision_directives(context, revision, directives) -> None: # noqa: ARG001
if config.cmd_opts.autogenerate:
script = directives[0]
if script.upgrade_ops.is_empty():
Expand Down
8 changes: 3 additions & 5 deletions db/seeds.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# This file should contain records you want created when you run flask db seed.
#
# Example:
# from yourapp.models import User
# `from yourapp.models import User`


# initial_user = {
# 'username': 'superadmin'
# }
# `initial_user = {'username': 'superadmin'}
# if User.find_by_username(initial_user['username']) is None:
# User(**initial_user).save()
# User(**initial_user).save()`
3 changes: 2 additions & 1 deletion src/core/database/linkrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __ping_url(url: str) -> bool:
httpx.codes.NO_CONTENT,
httpx.codes.NOT_MODIFIED,
)
except Exception:
except httpx.HTTPError as exc:
logger.exception("An error occurred when checking a URL for rotting.", exc_info=exc)
return False


Expand Down
4 changes: 2 additions & 2 deletions src/core/logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from datetime import datetime
from datetime import UTC, datetime
from logging.handlers import RotatingFileHandler
from pathlib import Path

Expand All @@ -15,7 +15,7 @@


def _linkrot_formatter(record: logging.LogRecord) -> str:
msg_date = datetime.fromtimestamp(record.created).strftime("%B %d, %Y @ %I:%M:%S %p")
msg_date = datetime.fromtimestamp(record.created, tz=UTC).strftime("%B %d, %Y @ %I:%M:%S %p")
return f""":warning: Webring Alert :warning:
Alert level: **{record.levelname.capitalize()}**
Date: {msg_date}
Expand Down
2 changes: 1 addition & 1 deletion src/views/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def embed(**kwargs) -> Response:

# Render the JavaScript module, taking care to indicate it's a JS file
# so browsers correctly load it
resp = make_response(render_template("webring-embed.js", **{"all_links": all_links}))
resp = make_response(render_template("webring-embed.js", all_links=all_links))
resp.mimetype = "text/javascript"
return resp

0 comments on commit 15648d1

Please sign in to comment.