Skip to content

[ty] Show truthiness in ConstraintSet display and simplify falsy error message#23913

Merged
AlexWaygood merged 1 commit intomainfrom
constraint-set-display
Mar 12, 2026
Merged

[ty] Show truthiness in ConstraintSet display and simplify falsy error message#23913
AlexWaygood merged 1 commit intomainfrom
constraint-set-display

Conversation

@AlexWaygood
Copy link
Member

Summary

A small quality-of-life improvement for playground debugging.

I always find it annoying when I do reveal_type(is_subtype_of(bool, int)) or similar and ty just tells me it's a ConstraintSet 😆 I have to do reveal_type(bool(is_subtype_of(bool, int))) to get the information I actually wanted out of ty. Now, we'll tell you whether the constraint set is known to be always, never or sometimes satisfied as part of the display of that constraint set:

from ty_extensions import is_subtype_of

reveal_type(is_subtype_of(bool, int))  # revealed: ConstraintSet[Literal[True]]
reveal_type(is_subtype_of(str, int))  # revealed: ConstraintSet[Literal[False]]

I also shortened the error message for static_assert.

Test Plan

mdtests updated

…r message

Display ConstraintSet with its satisfaction status:
- `ConstraintSet[Literal[True]]` when always satisfied
- `ConstraintSet[Literal[False]]` when never satisfied
- `ConstraintSet[bool]` when ambiguous

Also shorten "is statically known to be falsy" to "is always falsy" in
static_assert error messages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AlexWaygood AlexWaygood added internal An internal refactor or improvement ty Multi-file analysis & type inference labels Mar 12, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 12, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 12, 2026

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:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 60 diagnostics
+ Found 59 diagnostics

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 12, 2026

Memory usage report

Memory usage unchanged ✅

@AlexWaygood AlexWaygood merged commit 9e093db into main Mar 12, 2026
53 checks passed
@AlexWaygood AlexWaygood deleted the constraint-set-display branch March 12, 2026 23:23
carljm added a commit that referenced this pull request Mar 13, 2026
* main: (94 commits)
  Fix shell injection via `shell=True` in subprocess calls (#23894)
  [ty] Refactor `relation.rs` to store state on a struct rather than passing around 7 arguments every time we recurse (#23837)
  Don't return code actions for non-Python documents (#23905)
  [ty] Make the default database truly statically infallible (#23929)
  [ty] Add `Download` button to ty playground which creates a zip export (#23478)
  [ty] Respect `kw_only` overwrites in dataclasses (#23930)
  [ty] Clarify in diagnostics that `from __future__ import annotations` only stringifies type annotations (#23928)
  [ty]  Add a `Copy Markdown` button to playground (#23002)
  [ty] Fix folding range classification of lines starting with `#` (#23831)
  [ty] Fix folding ranges for notebooks (#23830)
  [ty] fix too-many-cycle panics when inferring literal type loop variables (#23875)
  Add `RegularCallableTypeOf` and `into_regular_callable` in `ty_extensions` (#23909)
  [ty] treat properties as full structural types (#23925)
  [ty] Avoid duplicated work during multi-inference (#23923)
  [ty]: make `possibly-missing-attribute` ignored by default
  [ty]: split out `possibly-missing-submodule` from `possibly-missing-attribute`
  Update astral-sh/setup-uv action to v7.5.0 (#23922)
  [ty] Show truthiness in ConstraintSet display and simplify falsy error message (#23913)
  Bump 0.15.6 (#23919)
  [ty] Narrow type context during collection literal inference (#23844)
  ...
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