Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ on:
- 'static/**'
- 'package.json'
- 'biome.json'
- '*.py'
- 'pyproject.toml'
- 'uv.lock'
push:
branches:
- main
paths:
- 'static/**'
- 'package.json'
- 'biome.json'
- '*.py'
- 'pyproject.toml'
Comment thread
escapedcat marked this conversation as resolved.
- 'uv.lock'

jobs:
lint:
lint-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -32,3 +38,24 @@ jobs:

- name: Run Biome
run: npm run lint

lint-python:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Install uv
run: pip install uv

- name: Install dependencies
run: uv sync --dev

- name: Run Ruff
run: uv run ruff check .
22 changes: 17 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,25 @@ pytest tests/test_linting.py::test_lint_area

### Linting/Formatting

No automated linting is configured. If adding:
Python linting with Ruff:

```bash
# Recommended: ruff for linting + formatting
uv add ruff
ruff check .
ruff format .
# Install dependencies
uv sync --dev

# Run linting
uv run ruff check .

# Auto-fix issues
uv run ruff check . --fix
```

Frontend linting with Biome (JavaScript/CSS):

```bash
npm install
npm run lint
npm run format
```

## Code Style Guidelines
Expand Down
34 changes: 25 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import os
from flask import Flask, render_template, request, jsonify, session, redirect, url_for
from flask_session import Session
import requests
import json
import os
import re
from datetime import datetime, timedelta
from geojson_rewind import rewind
from urllib.parse import urlparse
import re

import pyproj
import requests
from flask import (
Flask,
jsonify,
redirect,
render_template,
request,
session,
url_for,
)
from geojson_rewind import rewind
from shapely.geometry import shape
from shapely.ops import transform
import pyproj
from linting import lint_area_dict, lint_cache, LINT_RULES, FIX_ACTIONS, fix_migrate_icon, fix_bump_verified

from linting import (
FIX_ACTIONS,
LINT_RULES,
fix_bump_verified,
fix_migrate_icon,
lint_area_dict,
lint_cache,
)

app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'dev-secret-key-change-in-production')
Expand Down Expand Up @@ -1128,7 +1144,7 @@ def validate_url(value, allowed_values=None):
try:
result = urlparse(value)
return all([result.scheme, result.netloc]), "Invalid URL format"
except:
except Exception:
return False, "Invalid URL"


Expand Down
11 changes: 6 additions & 5 deletions linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import fnmatch
import re
import requests
from dataclasses import asdict, dataclass
from datetime import datetime, timedelta
from typing import Optional
from dataclasses import dataclass, asdict
from enum import Enum
from shapely.geometry import shape, Point
from typing import Optional

import requests
from shapely import STRtree
from shapely.geometry import shape


class Severity(Enum):
Expand Down Expand Up @@ -122,7 +123,7 @@ def check_icon_legacy_url(area: dict) -> Optional[LintResult]:
if not re.match(expected_pattern, icon_url):
return LintResult(
rule=LINT_RULES['icon-legacy-url'],
message=f'Icon URL does not match expected format',
message='Icon URL does not match expected format',
current_value=icon_url
)

Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

from app import app

if __name__ == "__main__":
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ dependencies = [
"pyproj>=3.7.0",
"gunicorn>=23.0.0",
]

[dependency-groups]
dev = [
"ruff>=0.15.2",
]

[tool.ruff]
line-length = 80
indent-width = 4

[tool.ruff.lint]
select = ["E", "F", "I"]
ignore = ["E501"]
37 changes: 33 additions & 4 deletions uv.lock

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