Closed
Description
Steps to reproduce
pip install pyenchant
- Create the file
test.py
with contentsdef foo(): """ # tpyo """
pylint --disable all --enable spelling --spelling-dict en_US test.py
Current behavior
Traceback (most recent call last):
File "/home/ganden/.pyenv/versions/jlab-test/bin/pylint", line 10, in <module>
sys.exit(run_pylint())
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
PylintRun(sys.argv[1:])
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/lint/run.py", line 349, in __init__
linter.check(args)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 862, in check
self._check_files(
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 896, in _check_files
self._check_file(get_ast, check_astroid_module, name, filepath, modname)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 922, in _check_file
check_astroid_module(ast_node)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1054, in check_astroid_module
retval = self._check_astroid_module(
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1099, in _check_astroid_module
walker.walk(ast_node)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
self.walk(child)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
callback(astroid)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/checkers/spelling.py", line 397, in visit_functiondef
self._check_docstring(node)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/checkers/spelling.py", line 411, in _check_docstring
self._check_spelling("wrong-spelling-in-docstring", line, start_line + idx)
File "/home/ganden/.pyenv/versions/3.8.3/envs/jlab-test/lib/python3.8/site-packages/pylint/checkers/spelling.py", line 347, in _check_spelling
col = line_segment.index(word)
ValueError: substring not found
Expected behavior
Find tpyo
correctly.
pylint --version output
pylint 2.6.0
astroid 2.4.2
Python 3.8.3 (default, Jul 24 2020, 19:51:30)
[GCC 10.1.0]
# and also
pyenchant 3.1.1
enchant 2.2.8
nuspell 3.1.2
More info
The following do not crash pylint (they behave as expected):
def foo():
"""# tpyo"""
"""# tpyo"""
def foo():
"""
# tpyo
"""
def foo():
"""
# cat
"""
def foo():
"""
tpyo # cat
"""
def foo():
"""
cat # tpyo
"""