pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.33k stars 1.14k forks source link

Invalid spelling error suggesting the word itself back #1605

Closed mitar closed 7 years ago

mitar commented 7 years ago

Steps to reproduce

  1. Have a docstring containing:
    Fit Bernoulli Naive Bayes classifier.
  2. Run pylint with spelling extension enabled.

Current behavior

We get the error:

C: 83, 0: Wrong spelling of a word 'Bernoulli' in a docstring:
  Fit Bernoulli Naive Bayes classifier.
      ^^^^^^^^^
Did you mean: ''Bernoulli''? (wrong-spelling-in-docstring)

Expected behavior

Or suggest some other word, and not exactly the same word. Or do not show an error.

pylint --version output

pylint 1.7.2, 
astroid 1.5.3
Python 3.5.2 (default, Oct 11 2016, 05:00:16) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]

Using pyenchant==1.6.11 and spelling-dict=en_US.

rogalski commented 7 years ago

Hello,

Unfortunately I cannot reproduce your issue. Can you provide extra info about your environment so we can pinpoint an exact problem?

Passing test (unittest_checker_spelling.py):

    @skip_on_missing_package_or_dict
    @set_config(spelling_dict=spell_dict)
    def test_github_issue_1605(self):
        module_to_check = astroid.parse('''
        """Fit Bernoulli Naive Bayes classifier."""
        ''')
        print(self.checker.spelling_dict.check('Bernoulli'))  # True
        print(self.checker.spelling_dict.suggest('Bernoulli'))  # ['Bernoulli']
        with self.assertNoMessages():
            self.checker.visit_module(module_to_check)
mac-mini:pylint rogalski$ enchant -v
@(#) International Ispell Version 3.1.20 (but really Enchant 1.6.0)
mitar commented 7 years ago

I made a reproduction here. Running pylint test.py gives:

************* Module test
C:  3, 0: Wrong spelling of a word 'Bernoulli' in a docstring:
  Fit Bernoulli Naive Bayes classifier.
      ^^^^^^^^^
Did you mean: ''Bernoulli''? (wrong-spelling-in-docstring)
C:  3, 0: Wrong spelling of a word 'Bayes' in a docstring:
  Fit Bernoulli Naive Bayes classifier.
                      ^^^^^
Did you mean: ''Bayes' or 'ayes' or 'byes' or 'bays''? (wrong-spelling-in-docstring)
Python 3.5.2
pyenchant==1.6.11

But I do not think binary enchant program is being used. The .so used is the one bundled with pyenchant.

rogalski commented 7 years ago

Occurs in 1.7.2, does not occur on master. Fixed in 9946d8b846f83de06ba9b017de2ea6b7f7439fd3