Skip to content

Commit 66f44ca

Browse files
committed
Switch to Ruff for linting and formatting
1 parent ddb136d commit 66f44ca

12 files changed

+30
-65
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.isort.cfg

Lines changed: 0 additions & 5 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
repos:
2-
- repo: https://github.com/asottile/seed-isort-config
3-
rev: v2.2.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.2.1
44
hooks:
5-
- id: seed-isort-config
6-
- repo: https://github.com/pre-commit/mirrors-isort
7-
rev: v5.10.1
8-
hooks:
9-
- id: isort
10-
- repo: https://github.com/ambv/black
11-
rev: 22.3.0
12-
hooks:
13-
- id: black
14-
- repo: https://github.com/pycqa/flake8
15-
rev: 3.9.2
16-
hooks:
17-
- id: flake8
18-
additional_dependencies:
19-
- 'flake8-coding==1.3.1'
20-
- 'flake8-copyright==0.2.2'
21-
- 'flake8-debugger==3.1.0'
22-
- 'flake8-mypy==17.8.0'
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
238
- repo: https://github.com/pre-commit/pre-commit-hooks
249
rev: v4.2.0
2510
hooks:

libmozevent/bus.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import os
77
import pickle
88
from queue import Empty
9-
from typing import Any
10-
from typing import Callable
9+
from typing import Any, Callable
1110

1211
import structlog
1312

@@ -81,7 +80,6 @@ async def receive(self, name: str):
8180
logger.debug("Wait for message on bus", queue=name, instance=queue)
8281

8382
if isinstance(queue, RedisQueue):
84-
8583
# Clean the last processed message as we are awaiting a new one on this queue
8684
if name in self.redis_messages:
8785
del self.redis_messages[name]

libmozevent/mercurial.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
from libmozdata.phabricator import PhabricatorPatch
2121

2222
from libmozevent.phabricator import PhabricatorBuild
23-
from libmozevent.utils import batch_checkout
24-
from libmozevent.utils import robust_checkout
23+
from libmozevent.utils import batch_checkout, robust_checkout
2524

2625
logger = structlog.get_logger(__name__)
2726

libmozevent/monitoring.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# -*- coding: utf-8 -*-
22
import asyncio
3-
from datetime import datetime
4-
from datetime import timedelta
5-
from typing import Dict
6-
from typing import List
3+
from datetime import datetime, timedelta
4+
from typing import Dict, List
75

86
import structlog
97
from taskcluster.helper import TaskclusterConfig
10-
from taskcluster.utils import slugId
11-
from taskcluster.utils import stringDate
8+
from taskcluster.utils import slugId, stringDate
129

1310
logger = structlog.get_logger(__name__)
1411

@@ -96,7 +93,6 @@ async def check_task(self):
9693
task_status = status["status"]["state"]
9794

9895
if task_status in ("failed", "completed", "exception"):
99-
10096
# Retry tasks in exception
10197
if task_status == "exception":
10298
await self.retry_task(group_id, hook_id, task_id)

libmozevent/pulse.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import fnmatch
88
import itertools
99
import json
10-
from typing import Dict
11-
from typing import List
12-
from typing import Tuple
10+
from typing import Dict, List, Tuple
1311

1412
import aioamqp
1513
import structlog
@@ -147,7 +145,6 @@ def find_matching_queues(self, payload_exchange: str, payload_routes: List[bytes
147145
"""
148146

149147
def _match(exchange, route):
150-
151148
# Exchanges must match exactly
152149
if payload_exchange != exchange:
153150
return False

libmozevent/utils.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
from redis import asyncio as aioredis
1616
from redis.asyncio.retry import Retry
1717
from redis.backoff import ExponentialBackoff
18-
from redis.exceptions import ConnectionError
19-
from redis.exceptions import ExecAbortError
20-
from redis.exceptions import PubSubError
21-
from redis.exceptions import RedisError
22-
from redis.exceptions import ResponseError
23-
from redis.exceptions import TimeoutError
24-
from redis.exceptions import WatchError
18+
from redis.exceptions import (
19+
ConnectionError,
20+
ExecAbortError,
21+
PubSubError,
22+
RedisError,
23+
ResponseError,
24+
TimeoutError,
25+
WatchError,
26+
)
2527

2628
log = structlog.get_logger(__name__)
2729

tests/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import os.path
1010
import urllib.parse
1111
from contextlib import contextmanager
12-
from datetime import datetime
13-
from datetime import timedelta
12+
from datetime import datetime, timedelta
1413
from unittest.mock import MagicMock
1514

1615
import hglib
@@ -20,9 +19,11 @@
2019
from taskcluster.utils import stringDate
2120

2221
from libmozevent.mercurial import Repository
23-
from libmozevent.phabricator import PhabricatorActions
24-
from libmozevent.phabricator import PhabricatorBuild
25-
from libmozevent.phabricator import PhabricatorBuildState
22+
from libmozevent.phabricator import (
23+
PhabricatorActions,
24+
PhabricatorBuild,
25+
PhabricatorBuildState,
26+
)
2627

2728
MOCK_DIR = os.path.join(os.path.dirname(__file__), "mocks")
2829

@@ -193,7 +194,6 @@ def _user_search(request):
193194
return (200, json_headers, _response(mock_name))
194195

195196
with responses.RequestsMock(assert_all_requests_are_fired=False) as resp:
196-
197197
resp.add(
198198
responses.POST,
199199
"http://phabricator.test/api/user.whoami",

tests/test_mercurial.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
import hglib
88
import pytest
99
import responses
10-
1110
from conftest import MockBuild
11+
1212
from libmozevent.bus import MessageBus
13-
from libmozevent.mercurial import MercurialWorker
14-
from libmozevent.mercurial import Repository
13+
from libmozevent.mercurial import MercurialWorker, Repository
1514

1615
MERCURIAL_FAILURE = """unable to find 'crash.txt' for patching
1716
(use '--prefix' to apply patch relative to the current directory)

tests/test_phabricator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest.mock import Mock
44

55
from conftest import MockBuild
6+
67
from libmozevent.phabricator import PhabricatorBuildState
78

89

@@ -14,7 +15,6 @@ def test_backoff(PhabricatorMock):
1415
build.state = PhabricatorBuildState.Queued
1516

1617
with PhabricatorMock as phab:
17-
1818
# Lower the max time to sleep to keep a speedy test
1919
phab.sleep = 0.1
2020

tests/test_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import pytest
99

1010
from libmozevent import utils
11-
from libmozevent.bus import AsyncRedis
12-
from libmozevent.bus import MessageBus
13-
from libmozevent.bus import RedisQueue
11+
from libmozevent.bus import AsyncRedis, MessageBus, RedisQueue
1412

1513

1614
def unexpected_error():

0 commit comments

Comments
 (0)