ruff/crates/ty_python_semantic/resources/mdtest/import
Aria Desires 6a1e91ce97
[ty] Check typeshed VERSIONS for parent modules when reporting failed stdlib imports (#20908)
This is a drive-by improvement that I stumbled backwards into while
looking into

* https://github.com/astral-sh/ty/issues/296

I was writing some simple tests for "thing not in old version of stdlib"
diagnostics and checked what was added in 3.14, and saw
`compression.zstd` and to my surprise discovered that `import
compression.zstd` and `from compression import zstd` had completely
different quality diagnostics.

This is because `compression` and `compression.zstd` were *both*
introduced in 3.14, and so per VERSIONS policy only an entry for
`compression` was added, and so we don't actually have any definite info
on `compression.zstd` and give up on producing a diagnostic. However the
`from compression import zstd` form fails on looking up `compression`
and we *do* have an exact match for that, so it gets a better
diagnostic!

(aside: I have now learned about the VERSIONS format and I *really* wish
they would just enumerate all the submodules but, oh well!)

The fix is, when handling an import failure, if we fail to find an exact
match *we requery with the parent module*. In cases like
`compression.zstd` this lets us at least identify that, hey, not even
`compression` exists, and luckily that fixes the whole issue. In cases
where the parent module and submodule were introduced at different times
then we may discover that the parent module is in-range and that's fine,
we don't produce the richer stdlib diagnostic.
2025-10-16 13:25:08 +00:00
..
basic.md [ty] Check typeshed VERSIONS for parent modules when reporting failed stdlib imports (#20908) 2025-10-16 13:25:08 +00:00
builtins.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
case_sensitive.md
conditional.md [ty] No union with Unknown for module-global symbols (#20664) 2025-10-01 16:40:30 +02:00
conflicts.md
conventions.md [ty] Rename "possibly unbound" diagnostics to "possibly missing" (#20492) 2025-09-23 14:26:55 +00:00
cyclic.md [ty] Recognize submodules in self-referential imports (#18005) 2025-05-13 16:59:11 +02:00
dunder_all.md [ty] No union with Unknown for module-global symbols (#20664) 2025-10-01 16:40:30 +02:00
errors.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
invalid_syntax.md
module_getattr.md [ty] No union with Unknown for module-global symbols (#20664) 2025-10-01 16:40:30 +02:00
namespace.md [ty] No union with Unknown for module-global symbols (#20664) 2025-10-01 16:40:30 +02:00
partial_stub_packages.md [ty] Add link for namespaces being partial (#20015) 2025-08-20 21:28:57 -07:00
relative.md [ty] fallback to resolve_real_module in file_to_module (#20461) 2025-09-24 21:15:35 -04:00
site_packages_discovery.md [ty] Improve tests for site-packages discovery (#18374) 2025-05-30 07:32:21 +01:00
star.md [ty] No union with Unknown for module-global symbols (#20664) 2025-10-01 16:40:30 +02:00
stub_packages.md [ty] Fix relative imports in stub packages (#18132) 2025-05-16 15:30:10 +02:00
stubs.md
tracking.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00