Skip to content

Conversation

@Gankra
Copy link
Contributor

@Gankra Gankra commented Nov 27, 2025

No description provided.

@Gankra Gankra added the ty Multi-file analysis & type inference label Nov 27, 2025
@Gankra Gankra added the server Related to the LSP server label Nov 27, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 27, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 27, 2025

mypy_primer results

Changes were detected when running on open source projects
beartype (https://github.com/beartype/beartype)
+ beartype/claw/_package/clawpkgtrie.py:66:29: warning[unsupported-base] Unsupported class base with type `<class 'dict[str, PackagesTrieBlacklist]'> | <class 'dict[str, Divergent]'>`
+ beartype/claw/_package/clawpkgtrie.py:247:29: warning[unsupported-base] Unsupported class base with type `<class 'dict[str, PackagesTrieWhitelist]'> | <class 'dict[str, Divergent]'>`
- Found 505 diagnostics
+ Found 507 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/wheel.py:98:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 44 diagnostics
+ Found 45 diagnostics

No memory usage changes detected ✅

@AlexWaygood
Copy link
Member

This specific one probably could be added as a Fix, right? There's no extra computation required for us to figure out where we need to import it from, so it wouldn't slow down type-checking for it to be added as a Fix when we emit the diagnostic.

Also, it's possible we shouldn't suggest this autofix when the Python version is <3.11. It was only added to the typing module on Python 3.11 -- on earlier versions, you can import it from typing_extensions, but we don't know whether the user actually has that installed as a dependency or not. (According to typeshed, typing_extensions is part of the stdlib, but don't believe typeshed's lies -- that's just so that typeshed can use new typing features in the stdlib stubs ;)

@Gankra
Copy link
Contributor Author

Gankra commented Nov 27, 2025

Oh that's an interesting wrinkle, we absolutely constantly suggest importing stuff from typing_extensions 😬

@AlexWaygood
Copy link
Member

AlexWaygood commented Nov 27, 2025

can you use the resolve_module() option you added that ignores stub files to check whether there is actually a version of typing_extensions installed into site-packages before suggesting a typing_extensions import?

@Gankra
Copy link
Contributor Author

Gankra commented Nov 27, 2025

Filed:

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.

I'm inclined to exclude typing_extensions from our auto-import machinery for now, here. But I'd also be okay leaving as is, given that these are all still manual actions

if symbol.module.file(db) == Some(file) || symbol.module.is_known(db, KnownModule::Builtins)
{
continue;
}

I think I'd prefer making this a Fix on the reveal_type diagnostic as it then also becomes available on the CLI

Comment on lines +26 to +27
let lint_name = lint_id.name();
if lint_name == UNRESOLVED_REFERENCE.name() || lint_name == UNDEFINED_REVEAL.name() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let lint_name = lint_id.name();
if lint_name == UNRESOLVED_REFERENCE.name() || lint_name == UNDEFINED_REVEAL.name() {
if lint_id == LintId::of(&UNRESOLVED_REFERENCE) || lint_id == LintId::of(&UNDEFINED_REVEAL){

@Gankra
Copy link
Contributor Author

Gankra commented Nov 28, 2025

Thinking about it more, just because it's Almost Definitely typing.reveal_type doesn't actually mean it is? It feels a little dubious to refuse to check if their project has its own reveal_type

@MichaReiser
Copy link
Member

Thinking about it more, just because it's Almost Definitely typing.reveal_type doesn't actually mean it is? It feels a little dubious to refuse to check if their project has its own reveal_type

I think it's fine as an unsafe fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server Related to the LSP server ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants