Skip to content

Conversation

@dcreager
Copy link
Member

We have several functions in ty_extensions for testing our constraint set implementation. This PR refactors those functions so that they are all methods of the ConstraintSet class, rather than being standalone top-level functions. 🎩 to @sharkdp for pointing out that KnownBoundMethod gives us what we need to implement that!

@dcreager dcreager added the internal An internal refactor or improvement label Oct 28, 2025
@dcreager dcreager requested a review from MichaReiser as a code owner October 28, 2025 14:11
@dcreager dcreager added the ty Multi-file analysis & type inference label Oct 28, 2025
@dcreager dcreager changed the title [ty] Move constraint set extension functions into ConstraintSet class [ty] Move constraint set mdtest functions into ConstraintSet class Oct 28, 2025
@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 ✅


static_assert(not is_subtype_of(bool, str))
static_assert(not is_subtype_of_given(True, bool, str))
static_assert(not ConstraintSet.always().implies_subtype_of(bool, str))
Copy link
Member

Choose a reason for hiding this comment

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

I find always so much easier to understand. Thanks for making this change.

Place::bound(Type::KnownBoundMethod(KnownBoundMethodType::PathOpen)).into()
}

Type::ClassLiteral(class)
Copy link
Member

Choose a reason for hiding this comment

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

I didn't review this part closely as it mostly seems about moving code around. I hope that's okay

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, a bunch of things that were KnownFunctions are now KnownBoundMethods.

@dcreager dcreager merged commit 4d2ee41 into main Oct 28, 2025
43 checks passed
@dcreager dcreager deleted the dcreager/constraint-set-api branch October 28, 2025 18:32
dcreager added a commit that referenced this pull request Oct 28, 2025
…straint-sets

* dcreager/subtype-given-typevars:
  better comment
  restructure a bit
  better names/comments
  simplify before implication
  two typevars!
  [ty] Reformat constraint set mdtests (#21111)
  [ty] Move constraint set mdtest functions into `ConstraintSet` class (#21108)
  Avoid sending an unnecessary "clear diagnostics" message for clients supporting pull diagnostics (#21105)
  Update Rust crate ignore to v0.4.24 (#20979)
@sharkdp
Copy link
Contributor

sharkdp commented Oct 29, 2025

This new API/DSL looks cool!

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.

4 participants