Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python 3.12 compatibility of the GitHub Action #497

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
airium \
black \
defusedxml \
pip-requirements-parser \
pygments \
pylint \
pytest>=6.2.0 \
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Fixed
- Revert running ``commit-range`` from the repository itself. This broke the GitHub
action.
- Python 3.12 compatibility in multi-line string scanning.
- Python 3.12 compatibility for the GitHub Action.
- Use the original repository working directory name as the name of the temporary
directory for getting the linter baseline. This avoids issues with Mypy when there's
an ``__init__.py`` in the repository root.
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ runs:
sys.exit(proc.returncode)
"

pip install pip-requirements-parser
akaihola marked this conversation as resolved.
Show resolved Hide resolved
if [ "$RUNNER_OS" == "Windows" ]; then
echo $entrypoint | python
else
Expand Down
7 changes: 5 additions & 2 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from subprocess import PIPE, STDOUT, run # nosec

from pkg_resources import parse_requirements
from pip_requirements_parser import parse_reqparts_from_string

LINTER_WHITELIST = {"flake8", "pylint", "mypy"}
ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
Expand All @@ -29,7 +29,10 @@
else:
req[0] += f"=={VERSION}"
linter_options = []
for linter_requirement in parse_requirements(LINT.replace(",", "\n")):
for requirement_string in LINT.split(","):
if not requirement_string.strip():
continue
linter_requirement = parse_reqparts_from_string(requirement_string).requirement
linter = linter_requirement.name
if linter not in LINTER_WHITELIST:
raise RuntimeError(
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ test =
flynt>=0.76,<0.78
isort>=5.0.1
mypy>=0.990
pip-requirements-parser
pygments
pytest>=6.2.0
pytest-darker
Expand Down