Skip to content

Commit 7c724cf

Browse files
committed
Switched from black to ruff-format and added extra rules
1 parent c63a980 commit 7c724cf

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ repos:
2020
hooks:
2121
- id: ruff
2222
args: [--fix, --show-fixes]
23-
24-
- repo: https://github.com/psf/black
25-
rev: 23.12.1
26-
hooks:
27-
- id: black
23+
- id: ruff-format
2824

2925
- repo: https://github.com/pre-commit/mirrors-mypy
3026
rev: v1.8.0

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ classifiers = [
2929
requires-python = ">=3.7"
3030
dependencies = [
3131
"asphalt ~= 4.6",
32+
"typing_extensions >= 4.6.0; python_version < '3.10'"
3233
]
3334
dynamic = ["version"]
3435

@@ -65,13 +66,19 @@ local_scheme = "dirty-tag"
6566

6667
[tool.ruff]
6768
line-length = 99
69+
target-version = "py37"
70+
71+
[tool.ruff.lint]
6872
select = [
69-
"E", "F", "W", # default flake-8
73+
"ASYNC", # flake8-async
74+
"E", "F", "W", # default Flake8
75+
"G", # flake8-logging-format
7076
"I", # isort
77+
"ISC", # flake8-implicit-str-concat
7178
"PGH", # pygrep-hooks
79+
"RUF100", # unused noqa (yesqa)
7280
"UP", # pyupgrade
7381
]
74-
target-version = "py37"
7582

7683
[tool.ruff.isort]
7784
known-first-party = ["asphalt.exceptions"]

src/asphalt/exceptions/api.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class ExtrasProvider(metaclass=ABCMeta):
4848
"""
4949

5050
@abstractmethod
51-
def get_extras(
52-
self, ctx: Context, reporter: ExceptionReporter
53-
) -> dict[str, Any] | None:
51+
def get_extras(self, ctx: Context, reporter: ExceptionReporter) -> dict[str, Any] | None:
5452
"""
5553
Return context specific extras for the given exception reporter backend.
5654

tests/test_component.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ def report_exception(
1717
self.reported_exception = exception
1818

1919

20-
@pytest.mark.parametrize(
21-
"install_default_handler", [True, False], ids=["default", "nodefault"]
22-
)
20+
@pytest.mark.parametrize("install_default_handler", [True, False], ids=["default", "nodefault"])
2321
@pytest.mark.asyncio
2422
async def test_start(caplog, install_default_handler):
2523
class DummyReporter(ExceptionReporter):

tests/test_report_exception.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@
1212
[True, False, "asphalt.exceptions", logging.getLogger("asphalt.exceptions")],
1313
ids=["autologger", "nologger", "strlogger", "loggerinstance"],
1414
)
15-
@pytest.mark.parametrize(
16-
"faulty_extras_provider", [False, True], ids=["goodextras", "badextras"]
17-
)
18-
@pytest.mark.parametrize(
19-
"faulty_reporter", [False, True], ids=["goodreporter", "badreporter"]
20-
)
15+
@pytest.mark.parametrize("faulty_extras_provider", [False, True], ids=["goodextras", "badextras"])
16+
@pytest.mark.parametrize("faulty_reporter", [False, True], ids=["goodreporter", "badreporter"])
2117
@pytest.mark.asyncio
22-
async def test_report_exception(
23-
logger, faulty_extras_provider, faulty_reporter, caplog
24-
):
18+
async def test_report_exception(logger, faulty_extras_provider, faulty_reporter, caplog):
2519
reported_exception = reported_message = None
2620

2721
class DummyReporter(ExceptionReporter):
@@ -59,9 +53,7 @@ def get_extras(self, ctx: Context, reporter: ExceptionReporter):
5953

6054
if faulty_reporter and logger:
6155
messages = [
62-
record.message
63-
for record in caplog.records
64-
if record.name == "asphalt.exceptions"
56+
record.message for record in caplog.records if record.name == "asphalt.exceptions"
6557
]
6658
assert messages[-1].startswith(
6759
"error calling exception reporter "
@@ -71,6 +63,4 @@ def get_extras(self, ctx: Context, reporter: ExceptionReporter):
7163

7264
def test_no_exception():
7365
exc = pytest.raises(Exception, report_exception, Context(), "test")
74-
exc.match(
75-
'missing "exception" parameter and no current exception present in sys.exc_info()'
76-
)
66+
exc.match('missing "exception" parameter and no current exception present in sys.exc_info()')

0 commit comments

Comments
 (0)