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

Show closest candidates for misspellings #824

Closed
JukkaL opened this issue Aug 19, 2015 · 7 comments
Closed

Show closest candidates for misspellings #824

JukkaL opened this issue Aug 19, 2015 · 7 comments

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 19, 2015

Instead of just saying "foobar" undefined try to look for closest candidates (using edit distance, for example) and give suggestions. For example: "get_stats" undefined, did you mean "getstats"?.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Aug 19, 2015

This would be useful for at least these things:

  • Attribute lookups
  • Keyword argument names
  • Module imports

@JukkaL
Copy link
Collaborator Author

JukkaL commented Aug 23, 2015

There is basic support for attribute lookups in the hack branch.

@JukkaL JukkaL removed the hack label Jun 7, 2016
@JelleZijlstra
Copy link
Member

This is done for attribute lookups, but not for the other things Jukka mentions.

@marcodoordash
Copy link
Contributor

marcodoordash commented May 6, 2019

#4934 adds more details and use cases to the Module imports part of this issue, pasting those here and closing it as a duplicate of this one.

Mypy can suggest correct spellings for some attributes, but it doesn't seem to work for module attributes:

from subprocess import popen  # Module 'subprocess' has no attribute 'popen'

import subprocess
subprocess.popen  # Module has no attribute "popen"

class Foobar:
    def do_it(self): pass
foobar  # Name 'foobar' is not defined

Foobar().doit()  # "Foobar" has no attribute "doit"; maybe "do_it"?

It would be better if mypy would suggest corrections for all of the cases in the above example.

@marcodoordash
Copy link
Contributor

looking at this one

ilevkivskyi pushed a commit that referenced this issue May 6, 2019
This fixes the following case outlined in #824:

```
from subprocess import popen  # Module 'subprocess' has no attribute 'popen'
```

is now

```
from subprocess import popen  # Module 'subprocess' has no attribute 'popen'; maybe "Popen"?
```
@Wuisch
Copy link
Contributor

Wuisch commented Nov 5, 2019

I took a shot at the keyword argument name case. Comments are welcome.

ilevkivskyi pushed a commit that referenced this issue Nov 7, 2019
This fixes the following case outlined in #824
```python
def f(other: A) -> None: pass
f(otter: A())
```
`Unexpected keyword argument "otter" for "f"`
is now 
`Unexpected keyword argument "otter" for "f";  did you mean "other"?`
ilevkivskyi pushed a commit that referenced this issue Nov 23, 2019
@ilevkivskyi
Copy link
Member

This is now fully implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants