Skip to content

Conversation

mtshiba
Copy link
Contributor

@mtshiba mtshiba commented May 12, 2025

Summary

I found this bug while working on #18041. The following code leads to infinite recursion.

from ty_extensions import is_disjoint_from, static_assert, TypeOf

class C:
    @property
    def prop(self) -> int:
        return 1

static_assert(not is_disjoint_from(int, TypeOf[C.prop]))

The cause is a trivial missing binding in is_disjoint_from. This PR fixes the bug and adds a test case (this is a simple fix and may not require a new test case?).

Test Plan

A new test case is added to mdtest/type_properties/is_disjoint_from.md.

Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅

@AlexWaygood AlexWaygood added bug Something isn't working ty Multi-file analysis & type inference labels May 12, 2025
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.

Wow, that's subtle. Great catch, thank you!

@AlexWaygood AlexWaygood merged commit 6f8f750 into astral-sh:main May 12, 2025
35 checks passed
@mtshiba mtshiba deleted the fix-is_disjoint_from branch May 12, 2025 14:30
@carljm
Copy link
Contributor

carljm commented May 12, 2025

Thank you!!

dcreager added a commit that referenced this pull request May 12, 2025
* main:
  [ty] Apply function specialization to all overloads (#18020)
  Add comma to panic message (#18048)
  [`flake8-pie`] Mark autofix for `PIE804` as unsafe if the dictionary contains comments (#18046)
  [ty] fix infinite recursion bug in `is_disjoint_from` (#18043)
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request May 21, 2025
## Summary

I found this bug while working on astral-sh#18041. The following code leads to
infinite recursion.

```python
from ty_extensions import is_disjoint_from, static_assert, TypeOf

class C:
    @Property
    def prop(self) -> int:
        return 1

static_assert(not is_disjoint_from(int, TypeOf[C.prop]))
```

The cause is a trivial missing binding in `is_disjoint_from`. This PR
fixes the bug and adds a test case (this is a simple fix and may not
require a new test case?).

## Test Plan

A new test case is added to
`mdtest/type_properties/is_disjoint_from.md`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants