Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project: use list of paths instead of pyright_cmd #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Mar 12, 2025

Thank you for creating mypy_primer! As of recently, we use it to run test Red Knot against (a small subset of) ecosystem projects. So far, we use a fork of mypy_primer, but I would like to clean up our implementation, add some improvements, and potentially upstream some of the changes — if you are interested.

As a first step, I would like to propose a change to the Project dataclass. So far, it stores a custom mypy_cmd and a pyright_cmd. I've noticed that the pyright_cmd in particular only comes in three variants:

  • pyright_cmd=None — which means that Pyright shouldn't run for this project
  • pyright_cmd="{pyright}" — which means that Pyright should be executed without passing any explicit paths
  • pyright_cmd="{pyright} some relative paths" — which means that the command line includes a list of explicit paths that are passed to Pyright.
    In particular, there are no pyright_cmd fields that pass additional flags to pyright.

For running other type checkers, it would be beneficial to have that information in a more structured form. This way we could reuse the list of explicit paths. So I'm proposing the following change:

  • For projects that previously used pyright_cmd=None, we add a new flag pyright_skip=True.
  • For projects that previously used pyright_cmd="{pyright}", we simply remove that pyright_cmd parameter. We consider that to be the new default.
  • For projects that previously used pyright_cmd="{pyright} some relative paths", we also remove the pyright_cmd parameter and add a new paths=["some", "relative", "paths"] field.

I have not attempted to change the representation for mypy, but I could do so if it seems desirable. I'd like to discuss the general approach first.

I tested this by running

mypy_primer --type-checker pyright

@sharkdp sharkdp changed the title Project: use list of paths instead of pyright_cmd Project: use list of paths instead of pyright_cmd Mar 12, 2025
@sharkdp sharkdp force-pushed the project-list-of-paths branch from 143df30 to edc5cc5 Compare March 12, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant