Skip to content

Wrong parameter types in the stubs for some assertpy functions #15326

@jeberger

Description

@jeberger

The stubs for assertpy.add_extension and assertpy.remove_extension should read:

def add_extension(func: Callable[..., AssertionBuilder]) -> None: ...
def remove_extension(func: Callable[..., AssertionBuilder]) -> None: ...

With the current definitions, the following (valid) code fails pyrefly check:

import assertpy
from assertpy import assert_that

def all (self, predicate):
    for val in self.val:
        predicate (val)
    return self
assertpy.add_extension (all)

assert_that ([1, 2, 3, 4]).all (lambda x: assert_that (x).is_less_than (10))
ERROR Argument `(self: Unknown, predicate: Unknown) -> Unknown` is not assignable to parameter `func` with type `(AssertionBuilder[Any]) -> AssertionBuilder[Any]` in function `assertpy.assertpy.add_extension` [bad-argument-type]
 --> main.py:8:25
  |
8 | assertpy.add_extension (all)
  |                         ^^^
  |
 INFO 1 error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions