Skip to content

Commit ba28192

Browse files
committed
Merge branch 'develop' into main
2 parents e956bce + b85841a commit ba28192

3 files changed

Lines changed: 35 additions & 15 deletions

File tree

app/modules/hubfile/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def _public_raw_url(self) -> str:
7272
"""
7373
from urllib.parse import quote
7474

75-
raw_url = url_for(
76-
"hubfile.raw_uvl", file_id=self.id, filename=self.name, _external=True
77-
)
75+
raw_url = url_for("hubfile.raw_uvl", file_id=self.id, filename=self.name, _external=True)
7876
if "localhost" not in raw_url and "127.0.0.1" not in raw_url:
7977
raw_url = raw_url.replace("http://", "https://", 1)
8078
# Percent-encode before injecting into another URL's query string,

app/modules/hubfile/routes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ def raw_uvl(file_id, filename):
245245
# as mimetype makes Flask append another "; charset=utf-8", resulting in
246246
# a duplicated parameter that some CORS-capable fetchers (notably the
247247
# FactLabel web app) choke on.
248-
return send_file(
249-
file_path, mimetype="text/plain", as_attachment=False, download_name=selected_file.name
250-
)
248+
return send_file(file_path, mimetype="text/plain", as_attachment=False, download_name=selected_file.name)
251249

252250

253251
@hubfile_bp.route("/hubfiles/<int:file_id>/workbench-content", methods=["GET"])

rosemary/commands/linter.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,54 @@
11
import os
22
import subprocess
3+
import sys
34

45
import click
56

67

7-
@click.command("linter", help="Runs flake8 linter on the 'app' and 'rosemary' directories.")
8+
@click.command(
9+
"linter",
10+
help="Runs flake8 + black --check + isort --check-only on 'app', 'rosemary' and 'core' "
11+
"(same checks as .github/workflows/CI_lint.yml).",
12+
)
813
def linter():
914

10-
# Define the directories to be checked with flake8
15+
# Mirror the CI Python Lint job exactly: flake8, black --check and
16+
# isort --check-only, all three pointed at the same three directories.
17+
# Running them locally via `rosemary linter` used to only cover flake8,
18+
# so PRs kept bouncing off the black/isort steps after being green
19+
# locally — fixed by running the full triad here.
1120
working_dir = os.getenv("WORKING_DIR", "")
1221
directories = [
1322
os.path.join(working_dir, "app"),
1423
os.path.join(working_dir, "rosemary"),
1524
os.path.join(working_dir, "core"),
1625
]
1726

18-
# Run flake8 in each directory
19-
for directory in directories:
20-
click.echo(f"Running flake8 on {directory}...")
21-
result = subprocess.run(["flake8", directory])
27+
checks = [
28+
("flake8", ["flake8", *directories]),
29+
("black --check", ["black", "--check", *directories]),
30+
("isort --check-only", ["isort", "--check-only", *directories]),
31+
]
2232

23-
# Check if flake8 encountered problems
33+
failed = []
34+
for label, cmd in checks:
35+
click.echo(click.style(f"\n==> {label}", fg="cyan"))
36+
result = subprocess.run(cmd)
2437
if result.returncode != 0:
25-
click.echo(click.style(f"flake8 found issues in {directory}.", fg="red"))
38+
click.echo(click.style(f"{label} found issues.", fg="red"))
39+
failed.append(label)
2640
else:
27-
click.echo(click.style(f"No issues found in {directory}. Congratulations!", fg="green"))
41+
click.echo(click.style(f"{label}: clean.", fg="green"))
42+
43+
if failed:
44+
click.echo(
45+
click.style(
46+
"\nFailed: " + ", ".join(failed) + ". Run `rosemary linter:fix` to auto-format.",
47+
fg="red",
48+
)
49+
)
50+
sys.exit(1)
51+
click.echo(click.style("\nAll lint checks passed. Congratulations!", fg="green"))
2852

2953

3054
@click.command(

0 commit comments

Comments
 (0)