diff --git a/.flake8 b/.flake8 deleted file mode 100644 index b23915d..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -ignore = E203, E231, E501, E722, W503, B950 -select = C,E,F,W,B,B9,I diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7125462..d7fc2a1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,19 +12,19 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python 3.7 + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: '3.11' - name: Install dependencies for build - run: pip install --upgrade setuptools wheel + run: pip install --upgrade setuptools build - name: Build - run: python setup.py sdist bdist_wheel + run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.pypi_password }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df86f85..c8fcc59 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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"] diff --git a/CHANGELOG.md b/CHANGELOG.md index 60f51dc..1ac4394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.2.0 (2023-05-04) + +### Incompatible changes + +- Require python 3.7+ #66 (thanks to @ssbarnea) + +### Other changes + +- Fix publish package workflow #74 +- Handle cases where pytest itself fails #70 (thanks to @edgarrmondragon) +- Adopt PEP-621 for packaging #65 (thanks to @ssbarnea) +- Bump pre-commit/action from 2.0.0 to 3.0.0 #56 + ## 0.1.8 (2022-12-20) No functionality change. diff --git a/MANIFEST.in b/MANIFEST.in index d07d8e6..ee937c8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include *.py include *.txt include *.yaml -include .flake8 include .pre-commit-config.yaml include CHANGELOG.md include LICENSE diff --git a/plugin_test.py b/plugin_test.py index 7e489ff..a580e9e 100644 --- a/plugin_test.py +++ b/plugin_test.py @@ -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" diff --git a/pyproject.toml b/pyproject.toml index baf4fd5..7e3ba1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" [project] # https://peps.python.org/pep-0621/#readme requires-python = ">=3.7" -version = "0.1.8" +version = "0.2.0" name = "pytest-github-actions-annotate-failures" description = "pytest plugin to annotate failed tests with a workflow command for GitHub Actions" readme = "README.md" @@ -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"] diff --git a/pytest_github_actions_annotate_failures/plugin.py b/pytest_github_actions_annotate_failures/plugin.py index df79c1d..0f71cc2 100644 --- a/pytest_github_actions_annotate_failures/plugin.py +++ b/pytest_github_actions_annotate_failures/plugin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import annotations @@ -8,9 +7,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 @@ -27,7 +25,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() @@ -124,13 +122,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):