Skip to content

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Oct 14, 2025

Summary

Rename "unwrapping" methods on Type from e.g. Type::into_class_literal to Type::as_class_literal. I personally find that name more intuitive, since no transformation of any kind is happening. We are just unwrapping from certain enum variants. An alternative would be try_as_class_literal, which would follow the strum naming scheme, but is slightly longer.

Also rename Type::into_callable to Type::try_upcast_to_callable. Note that I intentionally kept names like FunctionType::into_callable_type, because those return CallableType, not Option<Type<…>>.

Test Plan

Pure refactoring

@sharkdp sharkdp added the internal An internal refactor or improvement label Oct 14, 2025
@sharkdp sharkdp added the ty Multi-file analysis & type inference label Oct 14, 2025
@sharkdp sharkdp requested a review from dcreager as a code owner October 14, 2025 07:45
@github-actions
Copy link
Contributor

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@sharkdp sharkdp merged commit f73bb45 into main Oct 14, 2025
42 checks passed
@sharkdp sharkdp deleted the david/rename-type-unwrapping-functions branch October 14, 2025 07:53
dcreager added a commit that referenced this pull request Oct 14, 2025
…able

* dcreager/non-inferable-api:
  just the api parts
  [ty] Fix further issues in `super()` inference logic (#20843)
  [ty] Document when a rule was added (#20859)
  [ty] Treat `Callable` dunder members as bound method descriptors (#20860)
  [ty] Handle decorators which return unions of `Callable`s (#20858)
  Fix false negatives in `Truthiness::from_expr` for lambdas, generators, and f-strings (#20704)
  [ty] Rename Type unwrapping methods (#20857)
  Update `lint.flake8-type-checking.quoted-annotations` docs (#20765)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants