megalinter
megalinter copied to clipboard
Linter Pyright cannot import boto3 although I install it in PYTHON_PYRIGHT_PRE_COMMANDS
Describe the bug
In the .mega-linter.yml I have following config for pyright:
PYTHON_PYRIGHT_PRE_COMMANDS:
- command: pip3 install boto3 botocore kwargshelper docker jinja2 pyyaml requests slack
venv: pyright
When I run megalinter in a github action, within output I can see:
[Pre][PYTHON_PYRIGHT] run: [cd /venvs/pyright && source bin/activate && pip3 install boto3 botocore kwargshelper docker jinja2 pyyaml requests slack && deactivate] in cwd [/github/workspace]
Successfully installed MarkupSafe-2.1.5 boto3-1.34.36 botocore-1.34.36 certifi-2024.2.2 charset-normalizer-3.3.2 docker-7.0.0 idna-3.6 jinja2-3.1.3 jmespath-1.0.1 kwargshelper-2.7.1 packaging-23.2 python-dateutil-2.8.2 pyyaml-6.0.1 requests-2.31.0 s3transfer-0.10.0 six-1.16.0 slack-0.0.2 urllib3-2.0.7
Just a couple of lines below I see error:
--Error detail:
/github/workspace/packages/step/aws/__init__.py
/github/workspace/packages/step/aws/__init__.py:14:8 - error: Import "boto3" could not be resolved (reportMissingImports)
To Reproduce Steps to reproduce the behavior:
- Have a python code with an import of boto3 (or any other non-standard library)
- Configure a Github workflow to run pyright in megalinter.
- Push code/trigger Meagalinter in GH
- See an import error
Expected behavior When I install dependency in PYTHON_PYRIGHT_PRE_COMMANDS, the linter should be able to import it.
I have pre_commands install dependancies (via poetry):
PRE_COMMANDS:
- command: pip install poetry==1.3.2 && cd $GITHUB_WORKSPACE && poetry install
venv: mypy
- command: pip install poetry==1.3.2 && cd $GITHUB_WORKSPACE && poetry install
venv: pyright
- command: pip install poetry==1.3.2 && cd $GITHUB_WORKSPACE && poetry install
venv: pylint
Pylint and mypy are happy. Pyright doesn't find the dependencies.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.
Currently we are disabling the pyright linter.
Maybe python guru @Kurt-von-Laven would have a hint ? :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.