Skip to content

Functions with same signature but different parameter names. #2777

@sharmaeklavya2

Description

@sharmaeklavya2
def is_prime(n):
    # type: (int) -> bool
    return all(n % p != 0 for p in range(2, n))

def is_palindrome(m):
    # type: (int) -> bool
    return str(m) == ''.join(reversed(str(m)))

list1 = [is_prime, is_palindrome]
list2 = [is_prime, is_prime]

reveal_type(list1)
reveal_type(list2)

In this code, is_prime and is_palindrome have the same signature def (builtins.int) -> builtins.bool but different parameter names.

These are the revealed types:

  • list1: builtins.list[builtins.function*]
  • list2: builtins.list[def (n: builtins.int) -> builtins.bool]

I think the type of list1 should have been builtins.list[def (builtins.int) -> builtins.bool].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions