Support 'on'/'off' for type ignores
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Sometimes it's impossible to put # type: ignore on the offending line - e.g. because it's a multiline string, and there's nowhere you can put the comment outside the string that mypy will recognise. Or more generally, there might be a whole block of code for which mypy has a bunch of spurious complaints, so putting in dozens of # type: ignores is a bit noisy.
The only other option today is to have mypy ignore the entire file, but that has nasty ramifications - beyond just killing type checking for what might be 99% checkable, it also makes any imports of that file invalid, and so you have to spread ignore directives out like a messy spiderweb.
Thus, it'd be great if one could do e.g. # type: ignore on and # type: ignore off, so that the scope could be controlled precisely.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by tracing how mypy currently parses and applies # type: ignore directives, then determine how on and off should scope diagnostics across multiline strings and code blocks. Done means scoped ignores work without disabling checking for the rest of the file or invalidating imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100