After changing from Python 3.10.0 to 3.12.3 our workflow fails with:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.12.3/x64/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/pylint/__init__.py", line 25, in run_pylint
PylintRun(argv or sys.argv[1:])
File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/pylint/lint/run.py", line 207, in __init__
linter.check(args)
File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 650, in check
check_parallel(
File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/pylint/lint/parallel.py", line 152, in check_parallel
for (
File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/multiprocessing/pool.py", line 873, in next
raise value
astroid.exceptions.AstroidBuildingError: Building error when trying to create ast representation of module 'bibigrid.core.startup_rest'
Error: Process completed with exit code 1.
Workflow
name: linting
on: [push]
jobs:
linting-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12.3
uses: actions/setup-python@v4
with:
python-version: '3.12.3'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: ansible_lint
run: ansible-lint resources/playbook/roles/program_name/tasks/main.yaml
- name: pylint_lint
run: pylint program_name
in the pylint_lint step. I am unsure what causes this. One source suggested to add __init__.py
to all folders which I have now added, but this didn’t fix the issue.
Additional Information
In the past we used Python 3.10.0 for our linting, which worked fine, but that caused issues when we switched to Python 3.12.03 in our working environment. Python 3.12.03 apparently knows more pylint errors. Disabling some of those at certain places (aka pylint: disable=...
) raises an error on workflow execution with Python 3.10.0, because it doesn’t know them.
2
Answers
When your GitHub Linting Action fails with an Astroid building error while using Python 3.10.0, it is likely due to compatibility issues between the version of Astroid (or one of its dependencies) and Python 3.10.
This is a bug in astroid, you do not give the pylint/astroid version so:
pip freeze
on both sides), it’s frequent to have a local install with "old packages" that match the project requirements but then one of your dependency release a new package and that one get fetched in the CI. If this is a dependency issue you can set the dependency to what you have locally as a temp fix.