Skip to content

Commit 1827ebf

Browse files
ci: add pre-commit config with ruff linting and formatting (#130)
* ci: add pre-commit config with ruff linting and formatting Add .pre-commit-config.yaml with: - ruff: lint checking with auto-fix (matches CI lint.yml) - ruff-format: code formatting - Standard file checks: trailing whitespace, end-of-file, TOML/YAML validity, merge conflict markers * style: apply ruff formatting to 3 files Auto-formatted by ruff-format: - aw_core/util.py - tests/test_query2.py - tests/utils.py
1 parent 9e2ad03 commit 1827ebf

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-toml
8+
- id: check-yaml
9+
- id: check-merge-conflict
10+
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.15.4
13+
hooks:
14+
- id: ruff
15+
args: [--fix]
16+
- id: ruff-format

aw_core/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
logger = logging.getLogger(__name__)
66

77

8-
class VersionException(Exception):
9-
...
8+
class VersionException(Exception): ...
109

1110

1211
def _version_info_tuple() -> Tuple[int, int, int]: # pragma: no cover

tests/test_query2.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ def test_query2_query_functions(datastore):
341341
eventcount = query_bucket_eventcount(bid);
342342
asd = nop();
343343
RETURN = {{"events": events, "eventcount": eventcount}};
344-
""".format(
345-
bid=bid, bid_escaped=bid.replace("'", "\\'")
346-
)
344+
""".format(bid=bid, bid_escaped=bid.replace("'", "\\'"))
347345
try:
348346
bucket = datastore.create_bucket(
349347
bucket_id=bid, type="test", client="test", hostname="test", name="asd"
@@ -518,8 +516,7 @@ def test_query2_query_categorize(datastore):
518516
starttime = iso8601.parse_date("1970")
519517
endtime = starttime + timedelta(hours=1)
520518

521-
example_query = (
522-
rf"""
519+
example_query = rf"""
523520
events = query_bucket("{bid}");
524521
events = sort_by_timestamp(events);
525522
events = categorize(events, [
@@ -529,7 +526,6 @@ def test_query2_query_categorize(datastore):
529526
events_by_cat = merge_events_by_keys(events, ["$category"]);
530527
RETURN = {{"events": events, "events_by_cat": events_by_cat}};
531528
"""
532-
)
533529
try:
534530
bucket = datastore.create_bucket(
535531
bucket_id=bid, type="test", client="test", hostname="test", name="asd"

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TempTestBucket:
1515

1616
def __init__(self, datastore):
1717
self.ds = datastore
18-
self.bucket_id = f"test-{random.randint(0, 10 ** 4)}"
18+
self.bucket_id = f"test-{random.randint(0, 10**4)}"
1919

2020
def __enter__(self):
2121
self.ds.create_bucket(

0 commit comments

Comments
 (0)