diff options
author | Pedro Algarvio <pedro@algarvio.me> | 2017-12-14 10:59:13 +0000 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2017-12-14 11:59:13 +0100 |
commit | d42e74bb9428f895f36808d30bd8a1fe31e28f63 (patch) | |
tree | 69f4a7c19483701f5b88696a649be89398b6917f | |
parent | 04928d6c2ac1b5bde30f2db7101dca67a8b2ffe9 (diff) | |
download | pylint-git-d42e74bb9428f895f36808d30bd8a1fe31e28f63.tar.gz |
Fix `camelCase` spelling regex. (#1767)
This is a more permissive regex which also allows digits.
-rw-r--r-- | pylint/checkers/spelling.py | 2 | ||||
-rw-r--r-- | pylint/test/unittest_checker_spelling.py | 13 |
2 files changed, 6 insertions, 9 deletions
diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py index a47108a51..3ee005218 100644 --- a/pylint/checkers/spelling.py +++ b/pylint/checkers/spelling.py @@ -79,7 +79,7 @@ class CamelCasedWord(Filter): That is, any words that are camelCasedWords. """ - _pattern = re.compile(r"^([a-z]+[A-Z]\w+|[a-z]\w+[A-Z]+)") + _pattern = re.compile(r"^([a-z]+([\d]|[A-Z])(?:\w+)?)") def _skip(self, word): return bool(self._pattern.match(word)) diff --git a/pylint/test/unittest_checker_spelling.py b/pylint/test/unittest_checker_spelling.py index 07db9f708..75fc1b1c1 100644 --- a/pylint/test/unittest_checker_spelling.py +++ b/pylint/test/unittest_checker_spelling.py @@ -165,15 +165,12 @@ class TestSpellingChecker(CheckerTestCase): self._get_msg_suggestions('coment')))): self.checker.visit_classdef(stmt) - # With just a single lower and upper case letter is not good - stmt = astroid.extract_node( - 'class ComentAbc(object):\n """zN with a bad comment"""\n pass') - with self.assertAddsMessages( - Message('wrong-spelling-in-docstring', line=2, - args=('zN', 'zN with a bad comment', - '^^', - self._get_msg_suggestions('zN')))): + for ccn in ('xmlHttpRequest', 'newCustomer', 'newCustomerId', + 'innerStopwatch', 'supportsIpv6OnIos', 'affine3D'): + stmt = astroid.extract_node( + 'class TestClass(object):\n """{0} comment"""\n pass'.format(ccn)) self.checker.visit_classdef(stmt) + assert self.linter.release_messages() == [] @skip_on_missing_package_or_dict @set_config(spelling_dict=spell_dict) |