Skip to content

Commit

Permalink
Use ruff for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiralGT committed Nov 1, 2024
1 parent cffb495 commit d341998
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 116 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Linter

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install project
run: poetry install --no-interaction
- name: Run tests
run: |
poetry run ruff check
4 changes: 2 additions & 2 deletions botc/production.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from .settings import *
from .settings import * # noqa

# Configure the domain name using the environment variable
# that Azure automatically creates for us.
Expand Down Expand Up @@ -55,7 +55,7 @@
AZURE_STATIC_CONTAINER = os.environ.get("AZURE_STATIC_CONTAINER", "static")
STATIC_URL = f"https://{AZURE_CUSTOM_DOMAIN}/{AZURE_STATIC_CONTAINER}/"

STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") # noqa
BS_ICONS_CACHE = os.path.join(STATIC_ROOT, "icon_cache")

ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
Expand Down
127 changes: 28 additions & 99 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ requests = "^2.31.0"
django-cors-headers = "^4.3.0"
jsonschema = "^4.23.0"

[tool.poetry.dev-dependencies]
black = "*"
isort = "*"
mypy = "*"
uritemplate = "*"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
pytest-django = "^4.9.0"
pytest-cov = "^5.0.0"
isort = "*"
mypy = "*"
ruff = "*"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
8 changes: 4 additions & 4 deletions scripts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def clean(self):
f"This is not a valid script JSON. It does not conform to the schema at {schema_url}. \
Error message: {e.message}"
)
except jsonschema.exceptions.SchemaError as e:
except jsonschema.exceptions.SchemaError:
# The schema is invalid, just continue and assume it's valid
pass
except KeyError as e:
except KeyError:
# Our attempt to edit the schema has failed, just continue and assume it's valid
pass
except requests.exceptions.Timeout:
Expand All @@ -88,7 +88,7 @@ def clean(self):

if not isinstance(json, list):
raise ValidationError(
f"This is not a valid script JSON. Script JSONs are lists of character objects."
"This is not a valid script JSON. Script JSONs are lists of character objects."
)
# Author is optional so may not be entered or in JSON
entered_author = cleaned_data.get("author", None)
Expand All @@ -98,7 +98,7 @@ def clean(self):
json_name = script_json.get_name_from_json(json)
if not entered_name:
raise ValidationError(
f"No script name provided. A name must be entered."
"No script name provided. A name must be entered."
)
if json_name and entered_name:
if json_name != entered_name:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Generated by Django 5.1.1 on 2024-10-16 00:06

import django.db.models.deletion
from django.db import migrations, models


Expand Down
5 changes: 2 additions & 3 deletions scripts/validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.core.exceptions import ValidationError
from django.conf import settings
from versionfield.forms import VersionField
from scripts import models


def check_for_homebrew(item):
Expand All @@ -11,7 +10,7 @@ def check_for_homebrew(item):
if item.get("id", "") != "_meta":
if len(item) > 1:
raise ValidationError(
f"Only officially supported characters from https://bloodontheclocktower.com/script/ are supported"
"Only officially supported characters from https://bloodontheclocktower.com/script/ are supported"
)


Expand All @@ -21,7 +20,7 @@ def prevent_fishbucket(json):
"""
if len(json) > 50:
raise ValidationError(
f'The script database limits scripts to 50 characters. If you\'re trying to upload a "Fishbucket" script,'
"The script database limits scripts to 50 characters. If you\'re trying to upload a \"Fishbucket\" script,"
" this is automatically generated at https://botcscripts.com/script/all_roles"
)

Expand Down

0 comments on commit d341998

Please sign in to comment.