python / python/mypy

filter() type not properly derived from overriden __iter__()

Open
#10,485 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

This seems to be a problem shared between mypy and Pylance.
See description in Pylance bug report: https://github.com/microsoft/pylance-release/issues/1295#issue-892717386
mypy version used is 0.812

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue description and the linked Pylance bug report, then reproduce the reported filter() typing behavior using mypy 0.812. Trace how an overridden iter() contributes to the inferred filter type. Done means the intended type is derived correctly and the behavior is covered by an appropriate regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.