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: 2 comments 3 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.
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.