Add assertion passes

Open
#2,158 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the linked Implementation Overview, especially the type checker's passes and the semantic analysis phase. The issue has no concrete design or files identified, so first define the assertion boundaries, checks, and expected post-conditions in the discussion. Done means an agreed design and implemented checks that catch invalid pass transitions without cluttering normal code.

Written by the indexing model from the issue text.

Description

priority-2-low refactoring

(Stealing text from #2150)

It would be nice to have "assertion passes" between the different passes, to verify and document the post-conditions of each pass and pre-conditions of the next, without adding more clutter to the code. Examples (due to Jukka):

We could, for example, verify that unbound types don't leak from semantic analysis, and that every name expression refers to something after semantic analysis.

In addition, currently breaking something in e.g. the semantic analysis pass, is likely to result in a seemingly unrelated error message in latter phases. Of course it cannot be completely avoided, but it can be reduced.

I don't have any concrete design in mind. My intention is that the scope, nature, design and other details are to be fleshed out in this thread. The idea is very half-baked, so I'm looking forward for your comments.

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

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.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.