Skip to content

Stop using apply in library internals#27

Merged
msullivan merged 5 commits intomainfrom
eval-classes-what-to-do
Jan 12, 2026
Merged

Stop using apply in library internals#27
msullivan merged 5 commits intomainfrom
eval-classes-what-to-do

Conversation

@msullivan
Copy link
Collaborator

Instead, we traverse boxed mros of aliases and compute the types
of those. We'll need to add more caches probably, and think
a little bit more about what exact external APIs need to exist.

It is more-or-less renamed to flatten_type and then that now is used
by format_class._

@msullivan msullivan requested a review from 1st1 January 9, 2026 23:04
@msullivan msullivan force-pushed the eval-classes-what-to-do branch from 53e9e5f to b10b5bf Compare January 9, 2026 23:46
@msullivan msullivan force-pushed the eval-classes-what-to-do branch from b10b5bf to 73fcf1b Compare January 10, 2026 01:10
@dnwpark
Copy link
Contributor

dnwpark commented Jan 10, 2026

Did some quick poking around and this used to work but no longer does:

type _Works[Ts, I] = Literal[True]
type Works[Ts] = _Works[Ts, Length[Ts]]

type _Fails[Ts, I] = Literal[False]
type Fails[Ts] = _Fails[Ts, Literal[0]]


def test_consistency_01():
    t = eval_typing(Works[tuple[int, str]])
    assert t == Literal[True]

    t = eval_typing(Fails[tuple[int, str]])
    assert t == Literal[False]

return annos, dct


def flatten_class_new_proto(cls: type) -> type:
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't see this used anywhere?

@msullivan
Copy link
Collaborator Author

type _Works[Ts, I] = Literal[True]
type Works[Ts] = _Works[Ts, Length[Ts]]

type _Fails[Ts, I] = Literal[False]
type Fails[Ts] = _Fails[Ts, Literal[0]]


def test_consistency_01():
    t = eval_typing(Works[tuple[int, str]])
    assert t == Literal[True]

    t = eval_typing(Fails[tuple[int, str]])
    assert t == Literal[False]

Good catch

@msullivan msullivan merged commit c4b57a0 into main Jan 12, 2026
1 check passed
@msullivan msullivan deleted the eval-classes-what-to-do branch January 12, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants