Skip to content

Commit b2458a4

Browse files
authored
Add isort (import sort) Python linter to pre-commit (#709)
1 parent ac05944 commit b2458a4

File tree

8 files changed

+32
-15
lines changed

8 files changed

+32
-15
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ repos:
2020
files: \.(cmake|CMakeLists\.txt)$
2121
exclude: ^(3rdparty/|build.*/|install/)
2222

23+
# Python import sorting
24+
- repo: https://github.com/pycqa/isort
25+
rev: 5.13.2
26+
hooks:
27+
- id: isort
28+
args: [--settings-path, setup.cfg]
29+
2330
# Ruff Python linter
2431
- repo: https://github.com/charliermarsh/ruff-pre-commit
2532
rev: v0.14.9

scoreboard/main.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
from pathlib import Path
2-
from collections import defaultdict
3-
from datetime import datetime
4-
import csv
51
import argparse
6-
import subprocess
7-
import yaml
8-
import shutil
2+
import csv
93
import json
10-
from jinja2 import Environment, FileSystemLoader
114
import logging
5+
import shutil
6+
import subprocess
127
import sys
8+
from collections import defaultdict
9+
from datetime import datetime
10+
from pathlib import Path
1311
from zoneinfo import ZoneInfo # type: ignore
1412

13+
import yaml
14+
from jinja2 import Environment, FileSystemLoader
15+
1516
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
1617
logger = logging.getLogger(__name__)
1718

@@ -699,8 +700,8 @@ def main():
699700
pass
700701

701702
# Helper: compute evenly spaced dates for current semester (MSK)
702-
from datetime import date, timedelta
703703
import calendar
704+
from datetime import date, timedelta
704705

705706
def _abbr(day: date) -> str:
706707
return f"{day.day} {calendar.month_abbr[day.month]}"

scoreboard/tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
Pytest configuration and shared fixtures for scoreboard tests.
33
"""
44

5-
import pytest
6-
import tempfile
5+
import csv
76
import shutil
7+
import tempfile
88
from pathlib import Path
9+
10+
import pytest
911
import yaml
10-
import csv
1112

1213

1314
@pytest.fixture

scoreboard/tests/test_load_performance_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import csv
6+
67
from main import load_performance_data
78

89

scripts/create_perf_table.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import argparse
2+
import csv
23
import os
34
import re
5+
46
import xlsxwriter
5-
import csv
67

78
# -------------------------------
89
# Helpers and configuration

scripts/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python3
22

33
import os
4+
import platform
45
import shlex
56
import subprocess
6-
import platform
77
from pathlib import Path
88

99

scripts/variants_generation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import csv
2+
from pathlib import Path
3+
24
import numpy as np
35
from xlsxwriter.workbook import Workbook
4-
from pathlib import Path
56

67

78
def get_project_path():

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ exclude =
44
3rdparty
55
venv
66
.git
7+
8+
[tool:isort]
9+
skip =
10+
venv
11+
multi_line_output = 3

0 commit comments

Comments
 (0)