Git Product home page Git Product logo

Comments (5)

jakebailey avatar jakebailey commented on June 4, 2024 1

The comments above were specifically that nobody should be using the "venv" or "venv-path" flags of pyright; you can definitely use a virtualenv with this action. See this comment for my poetry recommendation: #10 (comment)

from pyright-action.

jakebailey avatar jakebailey commented on June 4, 2024

I don't recommend using venv/venvPath in pyright at all; the option is pretty specific to Eric's team's monorepo. For normal use, you should be getting the right venv onto PATH, or the right interpreter selected in your editor in the Python extension.

If you have a venv in CI, you will have much better success activating it in a previous step, but largely, it doesn't seem all that common to actually use a venv in CI.

from pyright-action.

jakebailey avatar jakebailey commented on June 4, 2024

I'm pretty sure the error is because those options can only be set in a config file, not via a flag. Which, again, is the byproduct of how this option works in pyright.

from pyright-action.

wolph avatar wolph commented on June 4, 2024

The thing is, if you're using setup-python with poetry and caching you need to use a virtualenv. Specifically, this config: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages

steps:
- uses: actions/checkout@v3
- name: Install poetry
  run: pipx install poetry
- uses: actions/setup-python@v4
  with:
    python-version: '3.9'
    cache: 'poetry'
- run: poetry install

Installing the dependencies for each run takes a lot of time (2-3 minutes for one of my repos) and with caching it only takes 6 seconds so caching helps a lot.

Naturally I could tell poetry to install right into the system dependencies but that makes caching impossible so I have to use a virtualenv here.

In case anyone else is running into this issue, this seems to work for me:

-   name: Get the Python bin path from poetry
    run: echo "PYTHON_BIN=$(poetry run which python)" >> $GITHUB_ENV
-   name: Linting with pyright
    uses: jakebailey/pyright-action@v1
    with:
        python-path: ${{ env.PYTHON_BIN }}
        extra-args: cf/${{ inputs.project }}

I tried python env info --path first but that step failed without a clear error. At the very least this method works both with container: ubuntu and a regular Github action run but it might not work for Windows jobs.

from pyright-action.

jakebailey avatar jakebailey commented on June 4, 2024

I've stuck some usage examples in the README to make this clearer.

from pyright-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.