Skip to content

Conversation

@AlexWaygood
Copy link
Member

Summary

If the user attempts to import a module that doesn't exist on their configured Python version, but does exist in the standard library on some other Python versions, give them a hint in the diagnostic that they may have misconfigured their Python version.

Demo:

image

Test Plan

Snapshots 'n' screenshots

@AlexWaygood AlexWaygood added ty Multi-file analysis & type inference diagnostics Related to reporting of diagnostics. labels May 31, 2025
@github-actions
Copy link
Contributor

github-actions bot commented May 31, 2025

mypy_primer results

No ecosystem changes detected ✅

@AlexWaygood AlexWaygood force-pushed the alex/pyversion-hint-import branch from f6afd5c to 56b3353 Compare May 31, 2025 12:35
…le that does not exist on their configured Python version
@AlexWaygood AlexWaygood force-pushed the alex/pyversion-hint-import branch from 56b3353 to d2240bc Compare May 31, 2025 12:36
@github-actions
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

AlexWaygood and others added 2 commits June 2, 2025 11:00
Co-authored-by: Micha Reiser <micha@reiser.io>
@AlexWaygood AlexWaygood force-pushed the alex/pyversion-hint-import branch from 68681a4 to 733d338 Compare June 2, 2025 10:49
@AlexWaygood AlexWaygood enabled auto-merge (squash) June 2, 2025 10:50
@AlexWaygood AlexWaygood merged commit e2d96df into main Jun 2, 2025
32 checks passed
@AlexWaygood AlexWaygood deleted the alex/pyversion-hint-import branch June 2, 2025 10:52
dcreager added a commit that referenced this pull request Jun 2, 2025
…aration

* origin/main:
  [ty] Treat lambda functions as instances of types.FunctionType (#18431)
  [ty] Fix false positives for legacy `ParamSpec`s inside `Callable` type expressions (#18426)
  [ty] Improve diagnostics if the user attempts to import a stdlib module that does not exist on their configured Python version (#18403)
  Update taiki-e/install-action action to v2.52.4 (#18420)
  Update docker/build-push-action action to v6.18.0 (#18422)
  [ty] Fix server hang after shutdown request (#18414)
  Update Rust crate libcst to v1.8.0 (#18424)
  Update Rust crate clap to v4.5.39 (#18419)
  Update cargo-bins/cargo-binstall action to v1.12.6 (#18416)
  Update dependency mdformat-mkdocs to v4.3.0 (#18421)
  Update pre-commit dependencies (#18418)
  Update dependency ruff to v0.11.12 (#18417)
  [ty] Ensure `Literal` types are considered assignable to anything their `Instance` supertypes are assignable to (#18351)
  [ty] Promote projects to good that now no longer hang (#18370)
  Sync vendored typeshed stubs (#18407)
  [ty] Fix multithreading related hangs and panics (#18238)
  Support relative `--ty-path` in ty-benchmark (#18385)
  [ty] Update docs for Python version inference (#18397)
  [ty] Infer the Python version from the environment if feasible (#18057)
  Implement template strings (#17851)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics Related to reporting of diagnostics. ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants