Skip to content

Commit d2881d4

Browse files
authored
chore: sync ruff rules (#836)
This change uses the same rules we use in other projects.
1 parent 46c10de commit d2881d4

34 files changed

+326
-151
lines changed

mergify_cli/ci/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import click
24

35
from mergify_cli import utils
@@ -99,7 +101,7 @@ def _process_tests_target_branch(
99101
type=JUnitFile(),
100102
)
101103
@utils.run_with_asyncio
102-
async def junit_upload( # noqa: PLR0913
104+
async def junit_upload(
103105
*,
104106
api_url: str,
105107
token: str,
@@ -170,7 +172,7 @@ async def junit_upload( # noqa: PLR0913
170172
type=JUnitFile(),
171173
)
172174
@utils.run_with_asyncio
173-
async def junit_process( # noqa: PLR0913
175+
async def junit_process(
174176
*,
175177
api_url: str,
176178
token: str,
@@ -262,7 +264,7 @@ def scopes(
262264
type=click.Path(exists=True),
263265
)
264266
@utils.run_with_asyncio
265-
async def scopes_send( # noqa: PLR0913, PLR0917
267+
async def scopes_send(
266268
api_url: str,
267269
token: str,
268270
repository: str,

mergify_cli/ci/detector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import json
24
import os
35
import pathlib

mergify_cli/ci/junit_processing/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import sys
24

35
import click
@@ -8,7 +10,7 @@
810
from mergify_cli.ci.junit_processing import upload
911

1012

11-
async def process_junit_files( # noqa: PLR0913
13+
async def process_junit_files(
1214
*,
1315
api_url: str,
1416
token: str,
@@ -98,7 +100,7 @@ async def process_junit_files( # noqa: PLR0913
98100
quarantine_final_failure_message = (
99101
"Unable to determine quarantined failures due to above error"
100102
)
101-
except Exception as exc: # noqa: BLE001
103+
except Exception as exc:
102104
msg = (
103105
f"❌ An unexpected error occurred when checking quarantined tests: {exc!s}"
104106
)
@@ -121,7 +123,7 @@ async def process_junit_files( # noqa: PLR0913
121123
repository=repository,
122124
spans=spans,
123125
)
124-
except Exception as e: # noqa: BLE001
126+
except Exception as e:
125127
click.echo(
126128
click.style(f"❌ Error uploading JUnit XML reports: {e}", fg="red"),
127129
err=True,

mergify_cli/ci/junit_processing/junit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import dataclasses
24
import os
35
import pathlib
@@ -45,7 +47,7 @@ async def files_to_spans(
4547
spans.extend(
4648
await junit_to_spans(
4749
run_id,
48-
pathlib.Path(filename).read_bytes(), # noqa: ASYNC240
50+
pathlib.Path(filename).read_bytes(),
4951
test_language=test_language,
5052
test_framework=test_framework,
5153
),
@@ -265,9 +267,9 @@ async def junit_to_spans(
265267

266268
spans.append(span)
267269

268-
testsuite_span._start_time = min_start_time # noqa: SLF001
270+
testsuite_span._start_time = min_start_time
269271
session_start_time = min(session_start_time, min_start_time)
270272

271-
session_span._start_time = session_start_time # noqa: SLF001
273+
session_span._start_time = session_start_time
272274

273275
return spans

mergify_cli/ci/junit_processing/quarantine.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
from __future__ import annotations
2+
13
import dataclasses
24
import typing
35

46
import click
57
import httpx
6-
from opentelemetry.sdk.trace import ReadableSpan
78
import opentelemetry.trace
89
import tenacity
910

1011
from mergify_cli import utils
1112

1213

14+
if typing.TYPE_CHECKING:
15+
from opentelemetry.sdk.trace import ReadableSpan
16+
17+
1318
@dataclasses.dataclass
1419
class QuarantineFailedError(Exception):
1520
message: str
@@ -71,7 +76,7 @@ async def check_and_update_failing_spans(
7176
span.name in quarantined_tests_tuple.quarantined_tests_names,
7277
)
7378

74-
span._attributes = dict(span.attributes) | { # noqa: SLF001
79+
span._attributes = dict(span.attributes) | {
7580
"cicd.test.quarantined": quarantined,
7681
}
7782
if (

mergify_cli/ci/junit_processing/upload.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1+
from __future__ import annotations
2+
13
import contextlib
24
import io
35
import logging
46
import typing
57

68
from opentelemetry.exporter.otlp.proto.http import Compression
79
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
8-
from opentelemetry.sdk.trace import ReadableSpan
910
from opentelemetry.sdk.trace import export
1011

1112
from mergify_cli import console
1213

1314

15+
if typing.TYPE_CHECKING:
16+
from opentelemetry.sdk.trace import ReadableSpan
17+
18+
1419
class UploadError(Exception):
1520
pass
1621

1722

1823
@contextlib.contextmanager
19-
def capture_log(logger: logging.Logger) -> typing.Generator[io.StringIO, None, None]:
24+
def capture_log(logger: logging.Logger) -> typing.Generator[io.StringIO]:
2025
# Create a string stream to capture logs
2126
log_capture_string = io.StringIO()
2227

mergify_cli/ci/scopes/changed_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ChangedFilesError(exceptions.ScopesError):
1414

1515

1616
def _run(cmd: list[str]) -> str:
17-
return subprocess.check_output(cmd, text=True, encoding="utf-8").strip()
17+
return subprocess.check_output(cmd, text=True, encoding="utf-8").strip() # noqa: S603
1818

1919

2020
def has_merge_base(base: str, head: str) -> bool:

mergify_cli/ci/scopes/config/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from mergify_cli.ci.scopes.config.root import Config
24
from mergify_cli.ci.scopes.config.root import ConfigInvalidError
35
from mergify_cli.ci.scopes.config.scopes import FileFilters

mergify_cli/ci/scopes/config/root.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import pathlib
24
import typing
35

@@ -20,7 +22,7 @@ class Config(pydantic.BaseModel):
2022
@classmethod
2123
def from_dict(
2224
cls,
23-
data: dict[str, typing.Any] | typing.Any, # noqa: ANN401
25+
data: dict[str, typing.Any] | typing.Any,
2426
) -> typing.Self:
2527
try:
2628
return cls.model_validate(data)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
from __future__ import annotations
2+
3+
14
class ScopesError(Exception):
25
pass

0 commit comments

Comments
 (0)