Skip to content

Type of lambda without context should not be inferred as Any #2631

Closed
@gvanrossum

Description

@gvanrossum

See #2567 (comment):

A lambda should always be at least least inferred as Callable (with a specific number of arguments). We know as much about it as we do about an unannotated def. This is really strange:

def f(x): return x
g = lambda x: x
reveal_type(f)
reveal_type(g)

Gives

__tmp__.py:3: error: Revealed type is 'def (x: Any) -> Any'
__tmp__.py:4: error: Revealed type is 'Any'

I think they should reveal the same type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions