python / python/mypy

New semantic analyzer: Refactor handling of is_inferred_def & co

Open
#6,458 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority-1-normal refactoring semantic-analyzer
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

There are several things that hold information about whether a type of variable should be inferred or not:

  • RefExpr.is_new_def
  • RefExpr.is_inferred_def
  • Var.is_ready
  • Var.is_inferred
  • TypeChecker.is_definition()

Such a variety of things is partially caused by the fact that special definitions like named tuples etc. used to have a Var() to which the lvalue was pointing. With the new analyzer we don't have this, so it would be good to clean-up/refactor the logic around inference after we merge the two analyzers.

See also https://github.com/python/mypy/issues/6453

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 files or tests are named. Start by reviewing RefExpr.is_new_def, RefExpr.is_inferred_def, Var.is_ready, Var.is_inferred, and TypeChecker.is_definition() after the two analyzers are merged; done means the inference state is handled consistently without the obsolete special-definition Var assumptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.