Skip to content

Commit e6054c5

Browse files
committed
Add UP007 back in, and fix a few more things, and update git workflows
1 parent ebfe146 commit e6054c5

File tree

12 files changed

+263
-124
lines changed

12 files changed

+263
-124
lines changed

β€Ž.github/workflows/lint.yamlβ€Ž

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
name: Lint
2-
1+
name: Lint and Format
32

43
on:
54
push:
65
branches: [ master, main ]
76
pull_request:
87
branches: [ master, main ]
98

10-
119
jobs:
12-
test:
13-
name: Lint
10+
lint-and-format:
11+
name: Lint and Format Check
1412
runs-on: ubuntu-latest
1513

1614
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-python@v4
15+
- name: Checkout code
16+
uses: actions/checkout@v4 # Use the latest stable version
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5 # Use the latest stable version
1920
with:
20-
python-version: '3.12'
21+
python-version: '3.12' # Specify your Python version
22+
23+
- name: Install Ruff
24+
run: pip install ruff
2125

22-
- name: Install Requirements
23-
run: pip install .[dev]
26+
- name: Run Ruff Checks (Linting)
27+
run: ruff check pose_evaluation
2428

25-
- name: Lint Code
26-
run: pylint pose_evaluation
29+
- name: Run Ruff Format Check
30+
# The --check flag makes 'ruff format' exit with a non-zero code if files are not formatted,
31+
# ensuring the CI pipeline fails.
32+
run: ruff format pose_evaluation --check

β€Ž.github/workflows/test.yamlβ€Ž

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
name: Test
22

3-
43
on:
54
push:
65
branches: [ master, main ]
76
pull_request:
87
branches: [ master, main ]
98

10-
119
jobs:
1210
test:
13-
name: Test
11+
name: Run Tests
1412
runs-on: ubuntu-latest
1513

1614
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-python@v4
15+
- name: Checkout code
16+
uses: actions/checkout@v4 # Recommended: uses latest stable v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5 # Recommended: uses latest stable v5
1920
with:
2021
python-version: '3.12'
22+
cache: 'pip' # Enable pip caching
2123

22-
- name: Install Requirements
24+
- name: Install Dependencies
25+
# This will install your project in editable mode and its dev dependencies,
26+
# leveraging the pip cache if available.
2327
run: pip install .[dev]
2428

25-
- name: Test Code
26-
run: pytest pose_evaluation
29+
- name: Run Pytest on pose_evaluation
30+
run: pytest pose_evaluation

β€Ž.pre-commit-config.yamlβ€Ž

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
files: ^pose_evaluation/
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.11.13 # Or the latest stable version
4+
# Ruff version.
5+
rev: v0.11.13
56
hooks:
6-
- id: ruff
7-
args: [--fix] # This includes formatting and many linting fixes
7+
# Run the linter.
8+
- id: ruff-check
9+
args: [--fix]
10+
# Run the formatter.
11+
- id: ruff-format
812

913
- repo: local
1014
hooks:
1115
- id: pytest
1216
name: pytest
13-
entry: pytest pose_evaluation
17+
entry: pytest # Just 'pytest'
1418
language: system
15-
types: [python]
19+
types: [python]
20+
pass_filenames: false

β€Žpose_evaluation/analysis/explore_metric_stats.pyβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def plot_pareto_frontier(df: pd.DataFrame):
9191
),
9292
hovertemplate=f"{DESCRIPTIVE_NAME_COL}: %{{customdata[0]}}<br>"
9393
# f"{'METRIC: %{{customdata[1]}}<br>' if METRIC_COL in group else ''}"
94-
f"{METRIC_COL}: %{{customdata[1]}}<br>" f"{col1}: %{{x:.3f}}<br>{col2}: %{{y:.3f}}<extra></extra>",
94+
f"{METRIC_COL}: %{{customdata[1]}}<br>"
95+
f"{col1}: %{{x:.3f}}<br>{col2}: %{{y:.3f}}<extra></extra>",
9596
)
9697
)
9798
else:

β€Žpose_evaluation/evaluation/combine_semantic_and_lookalike.pyβ€Ž

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,13 @@ def find_weird(df: pd.DataFrame, cols: list, source: str):
9494
# ASL-Lex Vocabulary for compatibility
9595
# Remove underscores unless they are immediately before digits at the end
9696
sem_related_df["subject"] = (
97-
sem_related_df["subject"]
98-
.str.replace("asllex:", "", regex=False)
99-
.str.replace("#", "", regex=False)
97+
sem_related_df["subject"].str.replace("asllex:", "", regex=False).str.replace("#", "", regex=False)
10098
# .str.upper()
10199
# .str.replace(r"_(?!\d+$)", "", regex=True)
102100
)
103101

104102
sem_related_df["object"] = (
105-
sem_related_df["object"]
106-
.str.replace("asllex:", "", regex=False)
107-
.str.replace("#", "", regex=False)
103+
sem_related_df["object"].str.replace("asllex:", "", regex=False).str.replace("#", "", regex=False)
108104
# .str.upper()
109105
# .str.replace(r"_(?!\d+$)", "", regex=True) # oh_i_see -> ohisee, but FISHING_2 left unchanged
110106
)

β€Žpose_evaluation/evaluation/create_metrics.pyβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import itertools
1111
import re
1212
from pathlib import Path
13-
from typing import Literal, Optional
13+
from typing import Literal
1414

1515
import pandas as pd
1616

@@ -123,9 +123,9 @@ def construct_metric(
123123
# Default Distances
124124
name_pieces.append(f"defaultdist{default_distance}")
125125
distance_measure.set_default_distance(default_distance)
126-
assert (
127-
f"default_distance:{default_distance}" in distance_measure.get_signature().format()
128-
), f"{distance_measure.default_distance}, {default_distance}"
126+
assert f"default_distance:{default_distance}" in distance_measure.get_signature().format(), (
127+
f"{distance_measure.default_distance}, {default_distance}"
128+
)
129129

130130
##########################################
131131
# FPS Strategy
@@ -182,7 +182,7 @@ def get_embedding_metrics(df: pd.DataFrame) -> list:
182182
def get_metrics(
183183
measures: list[DistanceMeasure] | None = None,
184184
include_return4=True,
185-
metrics_out: Optional[Path] = None,
185+
metrics_out: Path | None = None,
186186
include_masked: bool | None = False,
187187
):
188188
metrics = []

β€Žpose_evaluation/evaluation/filter_parquets.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def filter_parquet_files(
1818
glosses_to_include: str = typer.Option(..., help="Comma-separated list of glosses to include"),
1919
report_path: Path = typer.Option(None, help="Optional path to save a JSON report"),
2020
):
21-
glosses_set = set(g.strip().upper() for g in glosses_to_include.split(","))
21+
glosses_set = {g.strip().upper() for g in glosses_to_include.split(",")}
2222
typer.echo(f"πŸ“‚ Input path: {in_path}")
2323
typer.echo(f"πŸ“ Output path: {out_path}")
2424
typer.echo(f"πŸ“Œ Glosses to include: {len(glosses_set)}")
@@ -27,7 +27,7 @@ def filter_parquet_files(
2727
parquet_files = sorted(in_path.glob("*.parquet"))
2828
typer.echo(f"πŸ“ Parquets found: {len(parquet_files)}")
2929

30-
# 1–3: Build metric β†’ set of glosses
30+
# 1-3: Build metric β†’ set of glosses
3131
metric_to_glosses = defaultdict(set)
3232
gloss_to_files = defaultdict(list)
3333

β€Žpose_evaluation/evaluation/knn_eval.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ def get_metric_filtered_datasets(
199199
else:
200200
try:
201201
selected_metrics = [metric_values[int(choice) - 1]]
202-
except (ValueError, IndexError) as e: # Catch the original exception as 'e' (or 'err')
202+
except (ValueError, IndexError) as e: # Catch the original exception as 'e' (or 'err')
203203
typer.echo("Invalid selection.")
204-
raise typer.Exit(code=1) from e # Chain the new exception to the original one
204+
raise typer.Exit(code=1) from e # Chain the new exception to the original one
205205
else:
206206
if metric == "all":
207207
selected_metrics = metric_values

0 commit comments

Comments
Β (0)