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

Confusing "Could not resolve module" errors when verifying types of a sub-package. #9529

Open
mjpieters opened this issue Dec 2, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mjpieters
Copy link

mjpieters commented Dec 2, 2024

I tried to use the --verifytypes option on a submodule of a Python project. This works, except that the Public modules section contains a series of errors that indicates that pyright tried to resolve other submodules of the same project against the selected submodule.

Concretely, the project in question is prefect, where I wanted to validate their public SDK package prefect.main; the command line used is pyright --verifytypes prefect.main, and the resulting public modules section output is:

Public modules: 1
   prefect.main
   error: Could not resolve module "prefect.main.blocks"
   error: Could not resolve module "prefect.main.cli"
   error: Could not resolve module "prefect.main.cli.cloud"
   error: Could not resolve module "prefect.main.client"
   error: Could not resolve module "prefect.main.client.schemas"
   error: Could not resolve module "prefect.main.client.types"
   error: Could not resolve module "prefect.main.concurrency"
   error: Could not resolve module "prefect.main.concurrency.v1"
   error: Could not resolve module "prefect.main.deployments"
   error: Could not resolve module "prefect.main.deployments.steps"
   error: Could not resolve module "prefect.main.docker"
   error: Could not resolve module "prefect.main.events"
   error: Could not resolve module "prefect.main.events.cli"
   error: Could not resolve module "prefect.main.events.schemas"
   error: Could not resolve module "prefect.main.infrastructure"
   error: Could not resolve module "prefect.main.infrastructure.provisioners"
   error: Could not resolve module "prefect.main.input"
   error: Could not resolve module "prefect.main.locking"
   error: Could not resolve module "prefect.main.logging"
   error: Could not resolve module "prefect.main.records"
   error: Could not resolve module "prefect.main.runner"
   error: Could not resolve module "prefect.main.runtime"
   error: Could not resolve module "prefect.main.server"
   error: Could not resolve module "prefect.main.server.api"
   error: Could not resolve module "prefect.main.server.api.ui"
   error: Could not resolve module "prefect.main.server.database"
   error: Could not resolve module "prefect.main.server.events"
   error: Could not resolve module "prefect.main.server.events.models"
   error: Could not resolve module "prefect.main.server.events.schemas"
   error: Could not resolve module "prefect.main.server.events.services"
   error: Could not resolve module "prefect.main.server.events.storage"
   error: Could not resolve module "prefect.main.server.models"
   error: Could not resolve module "prefect.main.server.orchestration"
   error: Could not resolve module "prefect.main.server.schemas"
   error: Could not resolve module "prefect.main.server.services"
   error: Could not resolve module "prefect.main.server.utilities"
   error: Could not resolve module "prefect.main.server.utilities.messaging"
   error: Could not resolve module "prefect.main.server.utilities.schemas"
   error: Could not resolve module "prefect.main.settings"
   error: Could not resolve module "prefect.main.settings.models"
   error: Could not resolve module "prefect.main.settings.models.server"
   error: Could not resolve module "prefect.main.telemetry"
   error: Could not resolve module "prefect.main.testing"
   error: Could not resolve module "prefect.main.testing.standard_test_suites"
   error: Could not resolve module "prefect.main.types"
   error: Could not resolve module "prefect.main.utilities"
   error: Could not resolve module "prefect.main.utilities.schema_tools"
   error: Could not resolve module "prefect.main.workers"

The rest of the report is still extremely useful and as far as I am aware, correct.

Reproduce with:

python -m venv prefect-pyright-verifytypes
./prefect-pyright-verifytypes/bin/pip install pyright prefect
./prefect-pyright-verifytypes/bin/pyright --verifytypes prefect.main

Context

  • pyright version: 1.1.389
  • environment: macos 14.7.1 (23H222), arm64
  • python version: 3.12.3
@mjpieters mjpieters added the bug Something isn't working label Dec 2, 2024
@erictraut
Copy link
Collaborator

The --verifytypes command is intended to be run on an installed library. It appears that you've attempted to run the command on the repo for the library rather than in its installed form.

I tried installing prefect using pip install prefect. Then I ran pyright --verifytypes prefect, and it seemed to work fine for me. I don't see any of the above errors.

I'm going to close the issue because I think that pyright is working correctly. If I misunderstood the issue or missed something, let me know.

@erictraut erictraut closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@erictraut erictraut added the as designed Not a bug, working as intended label Dec 10, 2024
@mjpieters
Copy link
Author

mjpieters commented Dec 11, 2024

I tried installing prefect using pip install prefect. Then I ran pyright --verifytypes prefect, and it seemed to work fine for me. I don't see any of the above errors.

[...]

If I misunderstood the issue or missed something, let me know.

That's not the right reproducer.

I didn't run the command in the repository, I used pip install and ran pyright on the installed prefect.main package, so a specific package inside the prefect library. In short, run pyright --verifytypes prefect.main.

From my report:

Reproduce with

python -m venv prefect-pyright-verifytypes
./prefect-pyright-verifytypes/bin/pip install pyright prefect
./prefect-pyright-verifytypes/bin/pyright --verifytypes prefect.main

Perhaps that's not supposed to work either but let's make that explicit if so.

@erictraut erictraut reopened this Dec 11, 2024
@erictraut erictraut removed the as designed Not a bug, working as intended label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants