Giter Site home page Giter Site logo

pyright-action's Introduction

pyright-action

ci codecov

GitHub action for pyright. Featuring:

  • PR/commit annotations for errors/warnings.
  • Super fast startup, via:
    • Download caching.
    • No dependency on setup-node.
- uses: jakebailey/pyright-action@v1
  with:
    version: 1.1.311 # Optional (change me!)

Options

inputs:
  # Options for pyright-action
  version:
    description: 'Version of pyright to run. If not specified, the latest version will be used.'
    required: false
  working-directory:
    description: 'Directory to run pyright in. If not specified, the repo root will be used.'
    required: false
  no-comments:
    description: 'Disable issue/commit comments.'
    required: false
    default: 'false'

  # Shorthand for pyright flags
  create-stub:
    description: 'Create type stub file(s) for import. Note: using this option disables commenting.'
    required: false
  dependencies:
    description: 'Emit import dependency information. Note: using this option disables commenting.'
    required: false
  ignore-external:
    description: 'Ignore external imports for verify-types.'
    required: false
  level:
    description: 'Minimum diagnostic level (error or warning)'
    required: false
  project:
    description: 'Use the configuration file at this location.'
    required: false
  python-platform:
    description: 'Analyze for a specific platform (Darwin, Linux, Windows).'
    required: false
  python-path:
    description: 'Path to the Python interpreter.'
    required: false
  python-version:
    description: 'Analyze for a specific version (3.3, 3.4, etc.).'
    required: false
  skip-unannotated:
    description: 'Skip analysis of functions with no type annotations.'
    required: false
  stats:
    description: 'Print detailed performance stats. Note: using this option disables commenting.'
    required: false
  typeshed-path:
    description: 'Use typeshed type stubs at this location.'
    required: false
  venv-path:
    description: 'Directory that contains virtual environments.'
    required: false
  verbose:
    description: 'Emit verbose diagnostics. Note: using this option disables commenting.'
    required: false
  verify-types:
    description: 'Package name to run the type verifier on; must be an *installed* library. Any score under 100% will fail the build. Using this option disables commenting.'
    required: false
  warnings:
    description: 'Use exit code of 1 if warnings are reported.'
    required: false
    default: 'false'

  # Extra arguments (if what you want isn't listed above)
  extra-args:
    description: 'Extra arguments; can be used to specify specific files to check.'
    required: false

  # Removed in pyright 1.1.303
  lib:
    description: 'Use library code to infer types when stubs are missing.'
    required: false
    default: 'false'

Use with a virtualenv

The easiest way to use a virtualenv with this action is to "activate" the environment by adding its bin to $PATH, then allowing pyright to find it there.

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
  with:
    cache: 'pip'

- run: |
    python -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt

- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH

- uses: jakebailey/pyright-action@v1

Use with poetry

Similarly to a virtualenv, the easiest way to get it working is to ensure that poetry's python binary is on $PATH:

- uses: actions/checkout@v3

- run: pipx install poetry
- uses: actions/setup-python@v4
  with:
    cache: 'poetry'

- run: poetry install
- run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH

- uses: jakebailey/pyright-action@v1

pyright-action's People

Contributors

jakebailey avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyright-action's Issues

Module resolution change

Looks like 1.1.168 broke our CI pipelines. The errors indicate that pyright isn't able to resolve some of our stubs/typings. Unfortunately, I don't see anything obvious in the last couple commits :/

Pinning the action to 1.1.167 restores proper functionality.
Python 3.9.6

Using skipunannotated throws error

Activating skipunannotated yields

Run jakebailey/pyright-action@v1
/usr/bin/docker exec  0570a425a99594c7f7200fb917406d6e67ce96052308507cba4db691694b18bd sh -c "cat /etc/*release | grep ^ID"
pyright 1.1.232, node v16.20.2, pyright-action 1.7.0
/__e/node16/bin/node /__t/pyright/1.1.232/x64/package/index.js --skipunannotated true --outputjson
Loading configuration file at /sage/pyrightconfig.json
Assuming Python platform Linux
stubPath /sage/typings is not a valid directory.
Searching for source files
File or directory "/sage/true" does not exist.
No source files found.

It might be because of the old version (that we have to use for some unrelated reason), but I think the args should be simply --skipunannotated --outputjson instead of --skipunannotated true --outputjson

Too verbose output when ran many times

Typeshed's CI runs pyright on 3 different platforms and 5 different Python versions, meaning a total of 15 messages on each line with a problem (only 4 messages fit into the screenshot):

huge

This makes diffs quite unreadable. It would be nicer if the messages were combined together.

`Unexpected end of JSON input` when running action

When I run the action on my repro, it fails with Error: Unexpected end of JSON input. I use Pyright with VSC for the same source files, and it never complains. Here is the output from GitHub Actions:

...
2022-03-14T21:23:32.4948882Z ##[group]Run jakebailey/pyright-action@v1
2022-03-14T21:23:32.4949427Z with:
2022-03-14T21:23:32.4949756Z   working-directory: backend
2022-03-14T21:23:32.4950120Z   typeshed-path: typings
2022-03-14T21:23:32.4950568Z   lib: false
2022-03-14T21:23:32.4951266Z   warnings: false
2022-03-14T21:23:32.4951508Z   no-comments: false
2022-03-14T21:23:32.4951820Z env:
2022-03-14T21:23:32.4952109Z   pythonLocation: /opt/hostedtoolcache/Python/3.10.2/x64
2022-03-14T21:23:32.4952447Z ##[endgroup]
2022-03-14T21:23:32.8064249Z pyright 1.1.229
2022-03-14T21:23:32.9417607Z [command]/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/b25e2c0a-a3be-4856-9f15-528888bdeb08 -f /home/runner/work/_temp/99adb54d-05b7-4495-bb6d-cafb873a3e67
2022-03-14T21:23:33.2811323Z No configuration file found.
2022-03-14T21:23:33.2818455Z pyproject.toml file found at /home/runner/work/myproject/myproject/backend.
2022-03-14T21:23:33.2821073Z Loading pyproject.toml file at /home/runner/work/myproject/myproject/backend/pyproject.toml
2022-03-14T21:23:33.2864765Z No include entries specified; assuming /home/runner/work/myproject/myproject/backend
2022-03-14T21:23:33.3319394Z Searching for source files
2022-03-14T21:23:33.3613923Z Found 71 source files
2022-03-14T21:23:39.8617072Z ##[error]Unexpected end of JSON input
2022-03-14T21:23:39.8720539Z Post job cleanup.
2022-03-14T21:23:40.0238946Z [command]/usr/bin/git version
2022-03-14T21:23:40.0295210Z git version 2.35.1
...

Here is the Pyright part of my pyproject.toml file:

[tool.pyright]
pythonVersion = "3.10"
pythonPlatform = "Linux"

typeCheckingMode = "strict"

exclude = ["migrations", "node_modules", "typings", "bin"]
stubPath = "typings"
logLevel = "Trace"

enableTypeIgnoreComments = true
useLibraryCodeForTypes = true
autoImportCompletions = true
completeFunctionParens = true

reportImportCycles = "none"
reportMissingTypeStubs = "information"
reportIncompatibleVariableOverride = "none"

`Unexpected end of JSON input` error when using action vs locally

Hola! Thanks for helping to make such a great tool that makes type checking our team's Python much easier! 😄

I've been trying to implement pyright into a GitHub Actions pipeline recently, and I've kept running into this error. Pyright should be pretty up to date, and what's weird is that if I run it locally (with the same flags, including the version/platform/JSON flags), it works fine. A nice big blob of JSON is output.

I wonder if it's just too much JSON for one part of the program to handle? Running the same command locally produces ~17000 lines of JSON output.

Here's the output of our GitHub Actions step, if that helps:

GitHub Actions output
pyright 1.1.260, node v16.13.0, pyright-action 1.3.0
/actions-runner/externals/node16/bin/node /opt/hostedtoolcache/pyright/1.1.260/x64/package/index.js --outputjson --pythonplatform Linux --pythonversion 3.8 NaviGator/gnc/navigator_controller/nodes/gps_to_baselink_odom.py NaviGator/gnc/navigator_controller/nodes/mrac_controller.py ...other python files...

Loading configuration file at /tmp/runners/diamond/work/mil/mil/pyrightconfig.json

stubPath /tmp/runners/diamond/work/mil/mil/typings is not a valid directory.

Searching for source files

Found 443 source files

**Error: Unexpected end of JSON input**

Here's our pyrightconfig.json file, too, if that helps in debugging:

pyrightconfig.json
{
    "exclude": [
        "deprecated",
        "docs",
        "NaviGator/simulation/VRX",
        "NaviGator/perception/darknet_ros"
    ],
    "reportMissingTypeStubs": false,
    "pythonVersion": "3.8",
    "pythonPlatform": "Linux"
}

Thank you for your time. Have a good weekend!

How to set venv?

For some reason, PyRight makes one specify venvPath together with venv.

How to specify a venv with this action? extra-args: '--venv=...' doesn’t seem to work (“unexpected option --venv”)

Action fails to resolve package when installed with `poetry`

Sorry for the poorly explained issue.

I'm using your action in a context with poetry (using the snok/install-poetry action).

It seems that unless I explicitly use pip install . to install the deps manually then the action fails to resolve the output.
Here is both my config and an action output from a pip install .:
Config: https://github.com/AbstractUmbra/Hondana/blob/7abb4b7f648a4fff4213210e20e0d9767014577c/.github/workflows/coverage_and_lint.yaml#L63-L79
Action: https://github.com/AbstractUmbra/Hondana/actions/runs/4145028232/jobs/7168844087 (Run Pyright step)

Here it is with a poetry installed one:
Config: https://github.com/AbstractUmbra/Hondana/blob/a8653a55a0208a371f9b7248f1bfe8824472066d/.github/workflows/coverage_and_lint.yaml#L57-L71
Action: https://github.com/AbstractUmbra/Hondana/actions/runs/4145136918/jobs/7169102398

I assume this is related to how pyright itself resolves the venv path. I asked about this in another issue and locally on my server this works fine as you can see here:

$ poetry install                                   
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: Hondana (3.4.7)

$ poetry run python3 -c "import sys; print(sys.path)"
['', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/home/penumbra/.cache/pypoetry/virtualenvs/hondana-epKOD00U-py3.9/lib/python3.9/site-packages', '/home/penumbra/projects/personal/hondana']

$ poetry run pyright                                 
No configuration file found.
pyproject.toml file found at /home/penumbra/projects/personal/hondana.
Loading pyproject.toml file at /home/penumbra/projects/personal/hondana/pyproject.toml
Assuming Python version 3.9
Assuming Python platform Linux
stubPath /home/penumbra/projects/personal/hondana/typings is not a valid directory.
Searching for source files
Found 68 source files
pyright 1.1.290
0 errors, 0 warnings, 0 informations 
Completed in 5.04sec

I'm now wondering if perhaps my config is incorrect or so?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
  • codecov/codecov-action v3@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
npm
package.json
  • @actions/core ^1.10.1
  • @actions/http-client ~2.1.1
  • @actions/tool-cache ^2.0.1
  • @badrap/valita ^0.3.0
  • semver ^7.5.4
  • shell-quote ^1.8.1
  • @tsconfig/node16 ^16.1.1
  • @tsconfig/strictest ^2.0.2
  • @types/node ^16.18.59
  • @types/semver ^7.5.4
  • @types/shell-quote ^1.7.3
  • @typescript-eslint/eslint-plugin ^6.9.0
  • @typescript-eslint/parser ^6.9.0
  • @vitest/coverage-v8 ^0.34.6
  • dprint ^0.41.0
  • esbuild ^0.19.5
  • eslint ^8.52.0
  • eslint-plugin-simple-import-sort ^10.0.0
  • eslint-plugin-unicorn ^48.0.1
  • husky ^8.0.3
  • jest-serializer-path ^0.1.15
  • klona ^2.0.6
  • rimraf ^5.0.5
  • typescript ~5.2.2
  • vitest ^0.34.6
  • node >=16
  • npm 8.19.4

  • Check this box to trigger a request for Renovate to run again on this repository

service is down?

my github action is failing on this step with "Error: {"error":"Service Unavailable"}"

Support for bumping pyright version using dependabot

Thanks for a great action,

It would be nice to be able to pin the pyright version used but have in automatically upgraded. Would it be possible to specify the version of pyright in a package.json file or similar such that dependabot or similar tool automatically can update the version when a new pyrigth version is released. Could this be possible?

The README should mention that this action produces annotations

I had been aware of this action for some time, but never bothered to use it because this

     - uses: actions/setup-node@v3
       with:
         node-version: "18"
     - run: npm install -g pyright
     - run: pyright my_code

wasn't that difficult to configure, but now I've realized that your action actually produces annotations that appear in the PR! This is definitely your killer feature!

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (helpers:pinGitHubActionsDigests)

Support --verifytypes

Hello!

I'm not even sure where to begin with this bug report.

I believe I have either misunderstood how to set up this action, or it will not catch obvious errors.

I noticed it during this run, where the Type Coverage step passed successfully, however there were numerous type errors relating to return type were completely missed.
My action specification at the time looked like this, which should have inherited from the pyproject.toml file outlined here.

I have managed to manually install node, and run pyright manually in an action to verify that it will actually return these results, this can be viewed here in the "Run Pyright" step.

Could you please let me know if this is an issue with the action, or me? I very much like and appreciate the features you offer.

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.