Skip to content

Conversation

@Gankra
Copy link
Contributor

@Gankra Gankra commented Nov 20, 2025

No description provided.

@Gankra Gankra added server Related to the LSP server ty Multi-file analysis & type inference labels Nov 20, 2025
Comment on lines +684 to +685
let mut f = f.with_detail(TypeDetail::Type(self.ty));
f.write_str("<class '")?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is theoretically useless because the span logic will prefer the inner class.display_with but this is effectively a fallback if it doesn't.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 20, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

Comment on lines 718 to 723
SubclassOfInner::Dynamic(dynamic) => {
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
.write_str("type")?;
f.write_char('[')?;
write!(f, "{dynamic}")?;
f.write_char(']')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this invoke the Any/Unknown special cases? (Should that logic be factored out?)

Copy link
Member

Choose a reason for hiding this comment

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

Should this invoke the Any/Unknown special cases?

I think so, yes!

Should that logic be factored out?

Sure!

Copy link
Member

Choose a reason for hiding this comment

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

in fact, maybe that logic should just be moved to Type::definition() in types.rs?

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 20, 2025

mypy_primer results

Changes were detected when running on open source projects
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 43 diagnostics

No memory usage changes detected ✅

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Nice!

Comment on lines 701 to 702
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
.write_str("type")?;
Copy link
Member

Choose a reason for hiding this comment

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

I'm actually not totally sold that double-clicking on type in type[int] should take you anywhere, because type isn't a generic class in the same way as list[int] or dict[str, str]. Though it is true that all type[] types are instances of type

If we do want it to take you somewhere, though, it should take you to builtins.type rather than typing.Type, so that would be

Suggested change
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
.write_str("type")?;
f.with_detail(TypeDetail::Type(KnownClass::Type.to_class_literal(self.db)))
.write_str("type")?;

}
SubclassOfInner::Class(ClassType::Generic(alias)) => {
f.write_str("type[")?;
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
Copy link
Member

Choose a reason for hiding this comment

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

same here

Suggested change
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
f.with_detail(TypeDetail::Type(KnownClass::Type.to_class_literal(self.db)))

f.write_char(']')
}
SubclassOfInner::Dynamic(dynamic) => {
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
Copy link
Member

Choose a reason for hiding this comment

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

and here

Suggested change
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
f.with_detail(TypeDetail::Type(KnownClass::Type.to_class_literal(self.db)))

Comment on lines 718 to 723
SubclassOfInner::Dynamic(dynamic) => {
f.with_detail(TypeDetail::Type(Type::SpecialForm(SpecialFormType::Type)))
.write_str("type")?;
f.write_char('[')?;
write!(f, "{dynamic}")?;
f.write_char(']')
Copy link
Member

Choose a reason for hiding this comment

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

Should this invoke the Any/Unknown special cases?

I think so, yes!

Should that logic be factored out?

Sure!

@Gankra Gankra enabled auto-merge (squash) November 20, 2025 19:43
@Gankra Gankra merged commit 1b28fc1 into main Nov 20, 2025
40 checks passed
@Gankra Gankra deleted the gankra/more-click branch November 20, 2025 19:46
dcreager added a commit that referenced this pull request Nov 24, 2025
…d-typevar

* origin/main: (24 commits)
  [ty] Remove brittle constraint set reveal tests (#21568)
  [`ruff`] Catch more dummy variable uses (`RUF052`) (#19799)
  [ty] Use the same snapshot handling as other tests (#21564)
  [ty] suppress autocomplete suggestions during variable binding (#21549)
  Set severity for non-rule diagnostics (#21559)
  [ty] Add `with_type` convenience to display code (#21563)
  [ty] Implement docstring rendering to markdown (#21550)
  [ty] Reduce indentation of `TypeInferenceBuilder::infer_attribute_load` (#21560)
  Bump 0.14.6 (#21558)
  [ty] Improve debug messages when imports fail (#21555)
  [ty] Add support for relative import completions
  [ty] Refactor detection of import statements for completions
  [ty] Use dedicated collector for completions
  [ty] Attach subdiagnostics to `unresolved-import` errors for relative imports as well as absolute imports (#21554)
  [ty] support PEP 613 type aliases (#21394)
  [ty] More low-hanging fruit for inlay hint goto-definition (#21548)
  [ty] implement `TypedDict` structural assignment (#21467)
  [ty] Add more random TypeDetails and tests (#21546)
  [ty] Add goto for `Unknown` when it appears in an inlay hint (#21545)
  [ty] Add type definitions for `Type::SpecialForm`s (#21544)
  ...
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.

3 participants