Skip to content

test: add GenericCallable tests and documentation#24

Open
AliiiBenn wants to merge 1 commit intomainfrom
feature/generic-callable
Open

test: add GenericCallable tests and documentation#24
AliiiBenn wants to merge 1 commit intomainfrom
feature/generic-callable

Conversation

@AliiiBenn
Copy link
Member

Summary

This PR adds comprehensive tests for GenericCallable and documents why it doesn't need an evaluator.

Analysis

After deep analysis of PEP 827 and the existing codebase, I determined that GenericCallable does not need a dedicated evaluator. Here's why:

  1. PEP 827 Restriction: The PEP explicitly states that GenericCallable is restricted to Member type arguments:

    For now, we restrict the use of GenericCallable to the type argument of Member, to disallow its use for locals, parameter types, return types, nested inside other types, etc.

  2. Existing GetArg/GetArgs Support: The existing GetArg and GetArgs evaluators already handle GenericCallable:

    • GetArg[gc, GenericCallable, Literal[0]] returns the typevars tuple
    • GetArgs[gc, GenericCallable] returns the typevars
    • Access to index 1 (the callable lambda) returns Never by design
  3. No Transformation Needed: Unlike other operators that transform types, GenericCallable is a type-level marker that works through GetArg/GetArgs.

Changes

  • Add comment in _eval_operators.py explaining why no evaluator is needed
  • Add 5 comprehensive tests for GenericCallable:
    • test_generic_callable_basic - Basic evaluation
    • test_generic_callable_in_member - Usage within Member
    • test_generic_callable_getarg_typevars - GetArg returns typevars
    • test_generic_callable_getarg_callable - GetArg returns Never for callable
    • test_generic_callable_getargs - GetArgs works correctly

Test Results

All tests pass:

  • ✅ 169 passed
  • ✅ mypy passes
  • ✅ ruff passes

Related Issue

Closes #21


🤖 Generated with Claude Code

Add tests to verify GenericCallable behavior:
- Basic GenericCallable evaluation
- Usage within Member types
- GetArg/GetArgs integration

Note: GenericCallable does not need an evaluator because it is
handled via GetArg/GetArgs as per PEP 827 design (restricted to
Member type arguments).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Feature: Implement GenericCallable[Vs, lambda <vs>: Ty]

1 participant