Skip to content

Commit d1a4b30

Browse files
authored
chore: move to using Ruff (#71)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 1a87abb commit d1a4b30

File tree

6 files changed

+54
-26
lines changed

6 files changed

+54
-26
lines changed

.flake8

-3
This file was deleted.

.pre-commit-config.yaml

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.1.0
3+
rev: "v4.4.0"
44
hooks:
55
- id: check-added-large-files
66
- id: check-case-conflict
@@ -12,17 +12,14 @@ repos:
1212
- id: mixed-line-ending
1313
- id: requirements-txt-fixer
1414
- id: trailing-whitespace
15-
- id: fix-encoding-pragma
1615

1716
- repo: https://github.com/mgedmin/check-manifest
18-
rev: "0.42"
17+
rev: "0.49"
1918
hooks:
2019
- id: check-manifest
2120

22-
- repo: https://github.com/PyCQA/flake8
23-
rev: 3.8.3
21+
- repo: https://github.com/charliermarsh/ruff-pre-commit
22+
rev: "v0.0.262"
2423
hooks:
25-
- id: flake8
26-
additional_dependencies:
27-
- flake8-bugbear
28-
- flake8-import-order
24+
- id: ruff
25+
args: ["--fix", "--show-fixes"]

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
include *.py
22
include *.txt
33
include *.yaml
4-
include .flake8
54
include .pre-commit-config.yaml
65
include CHANGELOG.md
76
include LICENSE

plugin_test.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# -*- coding: utf-8 -*-
2-
import os
1+
from __future__ import annotations
32

4-
from packaging import version
3+
import os
54

65
import pytest
7-
6+
from packaging import version
87

98
pytest_plugins = "pytester"
109

pyproject.toml

+38
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,41 @@ changelog = "https://github.com/pytest-dev/pytest-github-actions-annotate-failur
4949

5050
[project.entry-points.pytest11]
5151
pytest_github_actions_annotate_failures = "pytest_github_actions_annotate_failures.plugin"
52+
53+
54+
[tool.ruff]
55+
select = [
56+
"E", "F", "W", # flake8
57+
"B", # flake8-bugbear
58+
"I", # isort
59+
"ARG", # flake8-unused-arguments
60+
"C4", # flake8-comprehensions
61+
"EM", # flake8-errmsg
62+
"ICN", # flake8-import-conventions
63+
"ISC", # flake8-implicit-str-concat
64+
"G", # flake8-logging-format
65+
"PGH", # pygrep-hooks
66+
"PIE", # flake8-pie
67+
"PL", # pylint
68+
"PT", # flake8-pytest-style
69+
"RET", # flake8-return
70+
"RUF", # Ruff-specific
71+
"SIM", # flake8-simplify
72+
"UP", # pyupgrade
73+
"YTT", # flake8-2020
74+
"EXE", # flake8-executable
75+
]
76+
extend-ignore = [
77+
"PLR", # Design related pylint codes
78+
"E501", # Line too long
79+
"PT004", # Use underscore for non-returning fixture (use usefixture instead)
80+
]
81+
target-version = "py37"
82+
unfixable = [
83+
"T20", # Removes print statements
84+
"F841", # Removes unused variables
85+
]
86+
isort.required-imports = ["from __future__ import annotations"]
87+
88+
[tool.ruff.per-file-ignores]
89+
"tests/**" = ["T20"]

pytest_github_actions_annotate_failures/plugin.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
from __future__ import annotations
43

@@ -7,9 +6,8 @@
76
from collections import OrderedDict
87
from typing import TYPE_CHECKING
98

10-
from _pytest._code.code import ExceptionRepr
11-
129
import pytest
10+
from _pytest._code.code import ExceptionRepr
1311

1412
if TYPE_CHECKING:
1513
from _pytest.nodes import Item
@@ -26,7 +24,7 @@
2624

2725

2826
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
29-
def pytest_runtest_makereport(item: Item, call):
27+
def pytest_runtest_makereport(item: Item, call): # noqa: ARG001
3028
# execute all other hooks to obtain the report object
3129
outcome = yield
3230
report: CollectReport = outcome.get_result()
@@ -93,13 +91,13 @@ def _error_workflow_command(filesystempath, lineno, longrepr):
9391
if lineno is not None:
9492
details_dict["line"] = lineno
9593

96-
details = ",".join("{}={}".format(k, v) for k, v in details_dict.items())
94+
details = ",".join(f"{k}={v}" for k, v in details_dict.items())
9795

9896
if longrepr is None:
99-
return "\n::error {}".format(details)
100-
else:
101-
longrepr = _escape(longrepr)
102-
return "\n::error {}::{}".format(details, longrepr)
97+
return f"\n::error {details}"
98+
99+
longrepr = _escape(longrepr)
100+
return f"\n::error {details}::{longrepr}"
103101

104102

105103
def _escape(s):

0 commit comments

Comments
 (0)