Skip to content

types.ModuleType attributes in the global namespace can have a different type rendered in the autocomplete tooltip to the one ty infers #2445

@AlexWaygood

Description

@AlexWaygood

Summary

For example, here the inferred type is str, but the type the autocompletion tooltip renders for the attribute is str | None:

Image

What's going on here is: in general, ty knows that the __file__ attribute for a module will be of type str | None. But for this module, ty infers a more precise type (str), because, well: we know this module has a file; we're checking it right now.

This special-casing is done here; it looks like we might need to make our autocompletion machinery aware of that special-casing somehow?

Version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletionsBugs or features relating to autocomplete suggestionsserverRelated to the LSP server

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions