posit-dev / posit-dev/positron
python LS: show a diagnostic when certain non-installed modules are imported
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.3k
- Forks
- 184
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 195
Description
Pyrefly usually is in charge of the missing-import diagnostic that shows a squiggly when you write import some_module_that_is_not_installed. But for the libraries below, Pyrefly bundles stubs, so the diagnostic purposely doesn't appear, even if the library isn't installed. Pyrefly can still do static analysis with those libraries but importing them will fail at runtime.
We could add a feature to our positron-python language server that displays a similar diagnostic for these libraries. I think it makes sense to live here, since our LS deals with other only-available-at-runtime considerations, though I could be convinced that this should be an upstream feature/toggle instead.
- 8 specific packages: boto3-stubs, botocore-stubs, conans-stubs, pandas-stubs, skimage-stubs, sklearn-stubs, sympy-stubs, vispy-stubs
- All 201 typeshed third-party stubs like requests, PyYAML, six, protobuf, etc.
- Whatever they add in the future
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the positron-python language server's handling of missing-import diagnostics and how Pyrefly exposes bundled stubs. Define the runtime-unavailable diagnostic behavior for the eight listed stub packages and the typeshed third-party stubs, then verify that imports of unavailable libraries produce the expected diagnostic without affecting available installations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100