Skip to content

Commit

Permalink
chore: move to using Ruff (pytest-dev#71)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored May 17, 2023
1 parent 1a87abb commit d1a4b30
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 26 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

15 changes: 6 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: "v4.4.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -12,17 +12,14 @@ repos:
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: fix-encoding-pragma

- repo: https://github.com/mgedmin/check-manifest
rev: "0.42"
rev: "0.49"
hooks:
- id: check-manifest

- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.262"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-import-order
- id: ruff
args: ["--fix", "--show-fixes"]
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include *.py
include *.txt
include *.yaml
include .flake8
include .pre-commit-config.yaml
include CHANGELOG.md
include LICENSE
Expand Down
7 changes: 3 additions & 4 deletions plugin_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
import os
from __future__ import annotations

from packaging import version
import os

import pytest

from packaging import version

pytest_plugins = "pytester"

Expand Down
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,41 @@ changelog = "https://github.com/pytest-dev/pytest-github-actions-annotate-failur

[project.entry-points.pytest11]
pytest_github_actions_annotate_failures = "pytest_github_actions_annotate_failures.plugin"


[tool.ruff]
select = [
"E", "F", "W", # flake8
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
]
extend-ignore = [
"PLR", # Design related pylint codes
"E501", # Line too long
"PT004", # Use underscore for non-returning fixture (use usefixture instead)
]
target-version = "py37"
unfixable = [
"T20", # Removes print statements
"F841", # Removes unused variables
]
isort.required-imports = ["from __future__ import annotations"]

[tool.ruff.per-file-ignores]
"tests/**" = ["T20"]
16 changes: 7 additions & 9 deletions pytest_github_actions_annotate_failures/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

from __future__ import annotations

Expand All @@ -7,9 +6,8 @@
from collections import OrderedDict
from typing import TYPE_CHECKING

from _pytest._code.code import ExceptionRepr

import pytest
from _pytest._code.code import ExceptionRepr

if TYPE_CHECKING:
from _pytest.nodes import Item
Expand All @@ -26,7 +24,7 @@


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

details = ",".join("{}={}".format(k, v) for k, v in details_dict.items())
details = ",".join(f"{k}={v}" for k, v in details_dict.items())

if longrepr is None:
return "\n::error {}".format(details)
else:
longrepr = _escape(longrepr)
return "\n::error {}::{}".format(details, longrepr)
return f"\n::error {details}"

longrepr = _escape(longrepr)
return f"\n::error {details}::{longrepr}"


def _escape(s):
Expand Down

0 comments on commit d1a4b30

Please sign in to comment.