Fix warnings
This commit is contained in:
@ -1,13 +1,6 @@
|
|||||||
default_language_version:
|
default_language_version:
|
||||||
python: python3.12
|
python: python3.12
|
||||||
repos:
|
repos:
|
||||||
# Apply a consistent format to pyproject.toml files.
|
|
||||||
# https://pyproject-fmt.readthedocs.io/en/latest/
|
|
||||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
||||||
rev: "1.5.3"
|
|
||||||
hooks:
|
|
||||||
- id: pyproject-fmt
|
|
||||||
|
|
||||||
# Automatically add trailing commas to calls and literals.
|
# Automatically add trailing commas to calls and literals.
|
||||||
- repo: https://github.com/asottile/add-trailing-comma
|
- repo: https://github.com/asottile/add-trailing-comma
|
||||||
rev: v3.1.0
|
rev: v3.1.0
|
||||||
@ -16,7 +9,7 @@ repos:
|
|||||||
|
|
||||||
# Some out-of-the-box hooks for pre-commit.
|
# Some out-of-the-box hooks for pre-commit.
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.5.0
|
rev: v4.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
- id: check-builtin-literals
|
- id: check-builtin-literals
|
||||||
@ -36,21 +29,21 @@ repos:
|
|||||||
|
|
||||||
# Automatically upgrade your Django project code
|
# Automatically upgrade your Django project code
|
||||||
- repo: https://github.com/adamchainz/django-upgrade
|
- repo: https://github.com/adamchainz/django-upgrade
|
||||||
rev: "1.15.0"
|
rev: "1.18.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: django-upgrade
|
- id: django-upgrade
|
||||||
args: [--target-version, "5.0"]
|
args: [--target-version, "5.0"]
|
||||||
|
|
||||||
# Run Pyupgrade on all Python files. This will upgrade the code to Python 3.12.
|
# Run Pyupgrade on all Python files. This will upgrade the code to Python 3.12.
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.15.0
|
rev: v3.16.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: ["--py312-plus"]
|
args: ["--py312-plus"]
|
||||||
|
|
||||||
# An extremely fast Python linter and formatter.
|
# An extremely fast Python linter and formatter.
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.1.9
|
rev: v0.4.8
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
- id: ruff
|
- id: ruff
|
||||||
@ -58,12 +51,6 @@ repos:
|
|||||||
|
|
||||||
# Static checker for GitHub Actions workflow files.
|
# Static checker for GitHub Actions workflow files.
|
||||||
- repo: https://github.com/rhysd/actionlint
|
- repo: https://github.com/rhysd/actionlint
|
||||||
rev: v1.6.26
|
rev: v1.7.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: actionlint
|
- id: actionlint
|
||||||
|
|
||||||
# Optimize .png files.
|
|
||||||
- repo: https://github.com/shssoichiro/oxipng
|
|
||||||
rev: v9.0.0
|
|
||||||
hooks:
|
|
||||||
- id: oxipng
|
|
||||||
|
@ -44,10 +44,6 @@ TIME_ZONE = "Europe/Stockholm"
|
|||||||
# If datetimes will be timezone-aware by default. If True, Django will use timezone-aware datetimes internally.
|
# If datetimes will be timezone-aware by default. If True, Django will use timezone-aware datetimes internally.
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
# Don't use Django's translation system
|
|
||||||
# TODO: We should probably make the site available in other languages at some point
|
|
||||||
USE_I18N = False
|
|
||||||
|
|
||||||
# Decides which translation is served to all users.
|
# Decides which translation is served to all users.
|
||||||
LANGUAGE_CODE = "en-us"
|
LANGUAGE_CODE = "en-us"
|
||||||
|
|
||||||
@ -147,7 +143,6 @@ STATIC_URL = "static/"
|
|||||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
|
|
||||||
# The absolute path to the directory where 'python manage.py collectstatic' will copy static files for deployment
|
# The absolute path to the directory where 'python manage.py collectstatic' will copy static files for deployment
|
||||||
# TODO: Should we store these on Cloudflare? Or at least in RAM to avoid disk I/O?
|
|
||||||
STATIC_ROOT: Path = BASE_DIR / "staticfiles"
|
STATIC_ROOT: Path = BASE_DIR / "staticfiles"
|
||||||
STATICFILES_DIRS: list[Path] = [BASE_DIR / "static"]
|
STATICFILES_DIRS: list[Path] = [BASE_DIR / "static"]
|
||||||
|
|
||||||
@ -161,8 +156,6 @@ STORAGES: dict[str, dict[str, str]] = {
|
|||||||
|
|
||||||
|
|
||||||
# Use Redis for caching
|
# Use Redis for caching
|
||||||
# TODO: Use a Unix socket instead of TCP/IP for Redis.
|
|
||||||
# TODO: Disallow specific commands. See https://redis.io/docs/management/security/#disallowing-specific-commands
|
|
||||||
REDIS_PASSWORD: str = os.getenv(key="REDIS_PASSWORD", default="")
|
REDIS_PASSWORD: str = os.getenv(key="REDIS_PASSWORD", default="")
|
||||||
REDIS_HOST: str = os.getenv(key="REDIS_HOST", default="")
|
REDIS_HOST: str = os.getenv(key="REDIS_HOST", default="")
|
||||||
REDIS_PORT: str = os.getenv(key="REDIS_PORT", default="6380")
|
REDIS_PORT: str = os.getenv(key="REDIS_PORT", default="6380")
|
||||||
|
12
manage.py
12
manage.py
@ -1,19 +1,23 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""Django's command-line utility for administrative tasks."""
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
"""Run administrative tasks."""
|
"""Run administrative tasks."""
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line # noqa: PLC0415
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
raise ImportError(
|
msg = (
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
"forget to activate a virtual environment?",
|
"forget to activate a virtual environment?"
|
||||||
|
)
|
||||||
|
raise ImportError(
|
||||||
|
msg,
|
||||||
) from exc
|
) from exc
|
||||||
execute_from_command_line(sys.argv)
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ readme = "README.md"
|
|||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.12"
|
python = "^3.12"
|
||||||
django = "^5.0.6"
|
django = "^5.0.6"
|
||||||
whitenoise = {extras = ["brotli"], version = "^6.6.0"}
|
whitenoise = { extras = ["brotli"], version = "^6.6.0" }
|
||||||
sentry-sdk = {extras = ["django"], version = "^1.45.0"}
|
sentry-sdk = { extras = ["django"], version = "^1.45.0" }
|
||||||
psycopg = {extras = ["binary"], version = "^3.1.19"}
|
psycopg = { extras = ["binary"], version = "^3.1.19" }
|
||||||
redis = {extras = ["hiredis"], version = "^5.0.5"}
|
redis = { extras = ["hiredis"], version = "^5.0.5" }
|
||||||
playwright = "^1.44.0"
|
playwright = "^1.44.0"
|
||||||
selectolax = "^0.3.17"
|
selectolax = "^0.3.17"
|
||||||
django-simple-history = "^3.7.0"
|
django-simple-history = "^3.7.0"
|
||||||
@ -25,6 +25,41 @@ djlint = "^1.34.1"
|
|||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
requires = [
|
requires = ["poetry-core"]
|
||||||
"poetry-core",
|
|
||||||
|
[tool.ruff]
|
||||||
|
# https://docs.astral.sh/ruff/settings/
|
||||||
|
target-version = "py312"
|
||||||
|
fix = true
|
||||||
|
unsafe-fixes = true
|
||||||
|
preview = true
|
||||||
|
lint.select = ["ALL"]
|
||||||
|
line-length = 119
|
||||||
|
lint.pydocstyle.convention = "google"
|
||||||
|
lint.ignore = [
|
||||||
|
"CPY001", # Missing copyright notice at top of file
|
||||||
|
"D100", # Checks for undocumented public module definitions.
|
||||||
|
"D101", # Checks for undocumented public class definitions.
|
||||||
|
"D102", # Checks for undocumented public method definitions.
|
||||||
|
"D104", # Missing docstring in public package.
|
||||||
|
"D105", # Missing docstring in magic method.
|
||||||
|
"D106", # Checks for undocumented public class definitions, for nested classes.
|
||||||
|
"ERA001", # Found commented-out code
|
||||||
|
"FIX002", # Line contains TODO
|
||||||
|
"COM812", # Checks for the absence of trailing commas.
|
||||||
|
"ISC001", # Checks for implicitly concatenated strings on a single line.
|
||||||
|
"DJ001", # Checks nullable string-based fields (like CharField and TextField) in Django models.
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
"**/tests/**" = [
|
||||||
|
"ARG", # Unused function args -> fixtures nevertheless are functionally relevant...
|
||||||
|
"FBT", # Don't care about booleans as positional arguments in tests, e.g. via @pytest.mark.parametrize()
|
||||||
|
"PLR2004", # Magic value used in comparison, ...
|
||||||
|
"S101", # asserts allowed in tests...
|
||||||
|
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
|
||||||
|
]
|
||||||
|
|
||||||
|
"**/migrations/**" = [
|
||||||
|
"RUF012", # Checks for mutable default values in class attributes.
|
||||||
]
|
]
|
||||||
|
@ -2,5 +2,5 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
|
|
||||||
class TwitchDropNotifierConfig(AppConfig):
|
class TwitchDropNotifierConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field: str = "django.db.models.BigAutoField"
|
||||||
name = "twitch_drop_notifier"
|
name: str = "twitch_drop_notifier"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from typing import ClassVar
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
@ -22,7 +24,7 @@ class Owner(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering: list[str] = ["name"]
|
ordering: ClassVar[list[str]] = ["name"]
|
||||||
verbose_name: str = "Owner"
|
verbose_name: str = "Owner"
|
||||||
db_table: str = "owner"
|
db_table: str = "owner"
|
||||||
db_table_comment: str = "An owner."
|
db_table_comment: str = "An owner."
|
||||||
@ -32,7 +34,6 @@ class Owner(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class Game(models.Model):
|
class Game(models.Model):
|
||||||
# TODO: Maybe int?
|
|
||||||
game_id = models.TextField(
|
game_id = models.TextField(
|
||||||
help_text="The ID of the game.",
|
help_text="The ID of the game.",
|
||||||
verbose_name="Game ID",
|
verbose_name="Game ID",
|
||||||
@ -54,7 +55,7 @@ class Game(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering: list[str] = ["display_name"]
|
ordering: ClassVar[list[str]] = ["display_name"]
|
||||||
verbose_name: str = "Game"
|
verbose_name: str = "Game"
|
||||||
db_table: str = "game"
|
db_table: str = "game"
|
||||||
db_table_comment: str = "A game."
|
db_table_comment: str = "A game."
|
||||||
@ -107,7 +108,7 @@ class Reward(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering: list[str] = ["name"]
|
ordering: ClassVar[list[str]] = ["name"]
|
||||||
verbose_name: str = "Reward"
|
verbose_name: str = "Reward"
|
||||||
db_table: str = "reward"
|
db_table: str = "reward"
|
||||||
db_table_comment: str = "A reward."
|
db_table_comment: str = "A reward."
|
||||||
@ -131,7 +132,7 @@ class TwitchChannel(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering: list[str] = ["name"]
|
ordering: ClassVar[list[str]] = ["name"]
|
||||||
verbose_name: str = "Twitch Channel"
|
verbose_name: str = "Twitch Channel"
|
||||||
db_table: str = "twitch_channel"
|
db_table: str = "twitch_channel"
|
||||||
db_table_comment: str = "A Twitch channel."
|
db_table_comment: str = "A Twitch channel."
|
||||||
@ -228,7 +229,7 @@ class TwitchDrop(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering: list[str] = ["name"]
|
ordering: ClassVar[list[str]] = ["name"]
|
||||||
verbose_name: str = "Twitch Drop"
|
verbose_name: str = "Twitch Drop"
|
||||||
db_table: str = "twitch_drop"
|
db_table: str = "twitch_drop"
|
||||||
db_table_comment: str = "A Twitch Drop."
|
db_table_comment: str = "A Twitch Drop."
|
||||||
|
Reference in New Issue
Block a user