Open dmytrokyrychuk opened 3 years ago
@dmytrokyrychuk,
The desire is to be able to support the scenario you describe. At the moment, it is not possible.
Related to #1253
A simpler request could be: don't spell check anything that can be type-checked. At least that doesn't require redoing a type-checker's work with multi-file analysis.
I'm interested in this too. I would like cspell to only spell-check identifiers that are defined by the code, not identifiers that are defined elsewhere. If there are spelling mistakes in referenced code, then cspell can find those spelling mistakes when checking the code where those identifiers are defined, and not in all references to those identifiers.
So I want these identifiers foobar
to be spell-checked:
foobar = "example"
with open("example.txt") as foobar: ....
for foobar in []: ...
def foobar(): ....
try:
...
except Exception as foobar:
....
class Foobar:
def __init__(self):
self.foobar = 'example'
But I don't want these identifiers foobar
to be spell-checked, because they are defined elsewhere:
import foobar
from foobar import foobar
foobar(foobar='example')
I would like to ignore certain words based on their role in a file. Related to #12.
Case 1
Consider the following Python example:
It would be nice to recognize that the word
chdir
is defined elsewhere, and therefore it should not be flagged as misspelled in the current file.Case 2
A more complicated example would be this:
It would be even better if there was a mechanism in cspell to recognize that
chdir
inos.chdir
references something that was defined elsewhere, although the wordchdir
did not occur on the import line directly. In general, attribute accesses should not be spellchecked, but attributes definitions should be checked. I think it would make sense to let the linter check that no illegal attribute accesses happen.Question
Is either of these cases possible currently, or do they need considerable changes to cspell?