All Poetry dependencies missing #3291
-
I've been using Megalinter for a while, but it's been a minute since I've touched a Python project with it, and... I don't recall ever have an issue using Poetry and Megalinter before - my understanding was that my
I've tried adding a pre-command to do a simple Python install (although this seems duplicative): PRE_COMMANDS:
- command: poetry install --no-root
cwd: workspace I've tried installing dependencies into each of the linters virtual environments (which hurt my soul): PRE_COMMANDS:
- command: poetry install --no-root
venv: pyright
- command: poetry install --no-root
venv: pylint I've even tried calling poetry run \
act \
--rm \
--container-architecture "linux/amd64" \
pull_request I don't recall ever having to do any of these things, which is making me think I'm missing something simple. Can anyone please point me to what that is? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Poking through the flavor PRE_COMMAND:
- command: python3 -m pip install poetry
venv: pylint
continue_if_failed: false
- command: python3 -m poetry install --no-root
venv: pylint
continue_if_failed: false This is wildly inefficient, if so - taking up easily 10x the time and disk space required for linting - so I'm hoping someone can point me toward a more sane solution wherein I can point linters toward a shared virtual environment. I'm not sure I understand the rationale for splitting out so many virtual environments in the first place.
Most comments I see online are "just disable the |
Beta Was this translation helpful? Give feedback.
-
I figured out an interim solution and, I'll be honest, I hate it. It does the following:
PRE_COMMANDS:
# Export the Poetry configuration to a `requirements.txt` file that each of the virtual environments can use
- command: python3 -m pip install poetry
cwd: root
continue_if_failed: false
- command: poetry export --without-hashes -f requirements.txt -o /venvs/requirements.txt
cwd: workspace
continue_if_failed: false
# Install dependencies for `pylint`
- command: python3 -m pip install --no-cache-dir -r /venvs/requirements.txt
venv: pylint
continue_if_failed: false
# Install dependencies for `pyright`
- command: python3 -m pip install --no-cache-dir -r /venvs/requirements.txt
venv: pyright
continue_if_failed: false I'm hoping @nvuillam or crew can impart some wisdom on me as to how this might be better managed. I really hate duplicating dependency installations on each and every test because there are dozens of virtual environments created... |
Beta Was this translation helpful? Give feedback.
-
Thanks @andrewvaughan for providing the solution. I also encounter this problem and find this discussion. I'm using GitHub Action. Here are some new update. Start from Just for anyone might needed, I find that my dependence is easy and I can copy
Still, I don't know why [Pre] run: [ls -la /venvs] in cwd [/github/workspace]
[Pre] result:
total 92
drwxr-xr-x 23 root root 4096 Apr 27 18:14 .
drwxr-xr-x 1 root root 4096 May 2 18:13 ..
drwxr-xr-x 4 root root 4096 Apr 27 18:13 ansible-lint
drwxr-xr-x 4 root root 4096 Apr 27 18:13 bandit
drwxr-xr-x 4 root root 4096 Apr 27 18:13 black
drwxr-xr-x 5 root root 4096 Apr 27 18:13 checkov
drwxr-xr-x 4 root root 4096 Apr 27 18:13 cpplint
drwxr-xr-x 4 root root 4096 Apr 27 18:13 djlint
drwxr-xr-x 4 root root 4096 Apr 27 18:13 flake8
drwxr-xr-x 4 root root 4096 Apr 27 18:13 isort
drwxr-xr-x 4 root root 4096 Apr 27 18:13 mypy
drwxr-xr-x 4 root root 4096 Apr 27 18:14 proselint
drwxr-xr-x 4 root root 4096 Apr 27 18:13 pylint
drwxr-xr-x 4 root root 4096 Apr 27 18:14 rst-lint
drwxr-xr-x 4 root root 4096 Apr 27 18:14 rstcheck
drwxr-xr-x 4 root root 4096 Apr 27 18:14 rstfmt
drwxr-xr-x 4 root root 4096 Apr 27 18:13 ruff
drwxr-xr-x 4 root root 4096 Apr 27 18:13 ruff-format
drwxr-xr-x 4 root root 4096 Apr 27 18:14 semgrep
drwxr-xr-x 4 root root 4096 Apr 27 18:14 snakefmt
drwxr-xr-x 4 root root 4096 Apr 27 18:14 sqlfluff
drwxr-xr-x 4 root root 4096 Apr 27 18:13 stylelint
drwxr-xr-x 4 root root 4096 Apr 27 18:14 yamllint |
Beta Was this translation helpful? Give feedback.
It is what it is! The joy of running a project that includes tons of non-standard dependencies.
I was able to make it work with the code above, and by limiting my
import
checks to just one tool, I only had to doPRE_COMMANDS
forpyright
(disablingpylint
). That's my recommendation for anyone else who comes across this thread:poetry
dependencies to arequirements.txt
fileimport
checking (in my case,pyright
)import
checking in all other tools via configrequirements.txt
viapip
in thePRE_COMMANDS
for the selected virtual environmentThat way, you're only installing your dependencies one extra time.
Thanks again.