megalinter icon indicating copy to clipboard operation
megalinter copied to clipboard

Linter Pyright cannot import boto3 although I install it in PYTHON_PYRIGHT_PRE_COMMANDS

Open xhujerr opened this issue 1 year ago • 1 comments
trafficstars

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:

  1. Have a python code with an import of boto3 (or any other non-standard library)
  2. Configure a Github workflow to run pyright in megalinter.
  3. Push code/trigger Meagalinter in GH
  4. See an import error

Expected behavior When I install dependency in PYTHON_PYRIGHT_PRE_COMMANDS, the linter should be able to import it.

xhujerr avatar Feb 07 '24 14:02 xhujerr

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.

dannystaple avatar Feb 09 '24 15:02 dannystaple

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.

github-actions[bot] avatar Mar 11 '24 00:03 github-actions[bot]

Currently we are disabling the pyright linter.

dannystaple avatar Mar 11 '24 08:03 dannystaple

Maybe python guru @Kurt-von-Laven would have a hint ? :)

nvuillam avatar Mar 11 '24 20:03 nvuillam

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.

github-actions[bot] avatar Apr 11 '24 00:04 github-actions[bot]