python / python/mypy

Consider making _ have type Any

Open
#15,298 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

_ if frequently used as a target location for discarded values. However, Mypy complains if values of different types are discared into it:

def f() -> int: return 1
def g() -> str: return '1'

_ = f()
_ = g()

Could it have type Any no matter what so that the above code works?

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

No file or test entry point is specified. Start with the Python reproduction and investigate how mypy infers and reuses the type of _ across consecutive assignments; done means the example type-checks while the intended behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.