Skip to content

Bug with filter #8704

@heckad

Description

@heckad
from typing import Optional
from typing import Sequence

from more_itertools import first


class A:
    def some_method(self):
        pass


def f(inp: Sequence[A]) -> Optional[A]:
    return first(filter(lambda a: a.some_method(), inp), None)

Output

test.py:13: error: Item "None" of "Optional[A]" has no attribute "some_method"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions