-
Notifications
You must be signed in to change notification settings - Fork 24
Pre-commit install hook doesn't actually install Pyright #225
Copy link
Copy link
Closed
Description
Pyright is only actually installed on the first use. This makes installing Pyright in a docker image so you avoid re-downloading it for every CI run (and depending on unreliable networks / github servers) difficult.
Here's what we have to do currently:
RUN python3 -m pip install --no-cache-dir pre-commit
# Make a git repo with a pre-commit config that we can use to pre-install the
# hook tools so they aren't installed on every run.
WORKDIR /opt/repo
# Add the pre-commit config (this just contains the hooks we use).
COPY .pre-commit-config.yaml .
# Pre-install tools used by the pre-commit hooks we have so that we don't
# have to install them on every CI run. pre-commit requires us to be in a git
# repo.
RUN git init --quiet && pre-commit install-hooks --config .pre-commit-config.yaml
# Unfortunately the Pyright hook does not *actually* install Pyright when you
# use install-hooks so we have to run it on some Python.
RUN printf '"""\nTest\n"""\n\nprint("hello")\n' > main.py && \
git config --global user.email "you@example.com" && \
git config --global user.name "Your Name" && \
git add . && \
git commit -m "Add python script" && \
pre-commit run -a
# This prevents the Pyright hook from accessing the network.
ENV PYRIGHT_PYTHON_IGNORE_WARNINGS=1
It's a mild annoyance. (Also slightly annoying that pre-commit forces you to make a git repo to install things.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels