Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jcrmatos opened this issue Apr 3, 2017 · 1 comment
Closed

Comments

@jcrmatos
Copy link

jcrmatos commented Apr 3, 2017

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

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 3, 2017

Mypy should probably do this by default. It doesn't make sense to just entirely disable type checking based on variable name since it's not uncommon to use _ for a real function. Also, hiding basic functionality behind a command line option would be questionable.

This is essentially a dupe of #465 so I'm closing this.

@JukkaL JukkaL closed this as completed Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants