Skip to content

Type inference regression involving filter(None, ...) #8093

@JukkaL

Description

@JukkaL

This example started generating errors after #8077:

from typing import Optional, TypeVar, Iterable, Iterator, List

_T = TypeVar('_T')

def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ...

x: Optional[str]

# Need type annotation for 'pagelets'
# List item 0 has incompatible type "Optional[str]"; expected "None"
pagelets = filter(None, [x])

The issue also happens with Python 2 filter(), at least.

cc @ilevkivskyi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy