Option to disable Python2/comment-style type annotations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Our codebase (all Python3) has a few places where we ended up writing comments that look like # type: some description ... prior to adding Mypy. They're usually within a larger multiline comment block when we're describing an expected Dict layout, e.g.
❯ cat foo.py
# Each Foo has the following fields:
# name: name of the foo
# display_name: human name
# type: type of foo it is
# tags: list of tags that apply to the foo
❯ mypy foo.py
foo.py:4: error: invalid syntax
Found 1 error in 1 file (errors prevented further checking)
Since we're only using Python3 and "proper" type annotations, it'd be nice if we could stop Mypy from trying to parse these types of comments. I know we could change our comment style to use dashes or something else that won't anger Mypy but it's annoying that it's necessary; and honestly colons are the better delimter anyways.
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
Start by tracing mypy's handling of Python 2-style type comments and the configuration entry points for Python 3-only code. Reproduce the issue with the shown mypy foo.py example, then add coverage for the option; done means those comments are ignored while proper Python 3 annotations continue to be checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100