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

Small refactor in spelling checker #6491

Conversation

Pierre-Sassoulas
Copy link
Member

Type of Changes

Type
🔨 Refactoring

Description

Refactor prior to #6137

@Pierre-Sassoulas Pierre-Sassoulas added the Maintenance Discussion or action around maintaining pylint or the dev workflow label May 2, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.14.0 milestone May 2, 2022
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the small-refactor-in-spelling-checker branch from 0320fac to 99e5703 Compare May 2, 2022 22:03
@coveralls
Copy link

coveralls commented May 2, 2022

Pull Request Test Coverage Report for Build 2262447303

  • 11 of 14 (78.57%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.167%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pylint/checkers/spelling.py 10 13 76.92%
Totals Coverage Status
Change from base Build 2262354182: 0.0%
Covered Lines: 15832
Relevant Lines: 16636

💛 - Coveralls

if lower_cased_word not in self.unknown_words:
if (
lower_cased_word not in self.unknown_words
and self.private_dict_file is not None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a change in behaviour?

Copy link
Member Author

@Pierre-Sassoulas Pierre-Sassoulas May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If self.private_dict_file is None the write() call would crash pylint. It's never happening but you have to read the whole class workflow to realize that, and mypy can't. I'll do a follow-up refactor to initialize thing in the constructor where it should be clearer.

original_line = line
try:
initial_space = re.search(r"^[^\S]\s*", line).regs[0][1]
# The mypy warning is caught by the except statement
initial_space = re.search(r"^\s+", line).regs[0][1] # type: ignore[union-attr]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a simplification in the regex here on top of the mypy ignore. [^\S] is \s and \s\s* is \s+

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the small-refactor-in-spelling-checker branch from 67a0378 to f12d026 Compare May 3, 2022 07:20
@Pierre-Sassoulas Pierre-Sassoulas merged commit 585a574 into pylint-dev:main May 3, 2022
@Pierre-Sassoulas Pierre-Sassoulas deleted the small-refactor-in-spelling-checker branch May 3, 2022 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining pylint or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants