Skip to content

Suggestion: Add optional command line flag to disable type checking for _ #3114

Closed
@jcrmatos

Description

@jcrmatos

Hello,

I would like to suggest adding an optional command line flag to disable type checking for _.
It is a Python idiom to use _ when the variable will not be used like this
for _ in range(10):
or when the return from a function is not needed, like this
a, b, _ = some_func()

Right now (mypy 0.501) I get this error

data_processing.py:993: error: Incompatible types in assignment (expression has
type List[List[str]], variable has type "str")

when running this
metadata_dic, _, _ = extract_data(data_lst)
because the return of the extract_data function is
Tuple[OrderedDict, List[List[str]], List[List[str]]]
and some code above that assignment also uses _, but it's type is str.
mypy alerts there is an incompatible type assignment, which would be correct it it was a common variable.

Best regards,

JM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions