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

[spelling checker] Better help message and code organization #8338

Merged

Conversation

Pierre-Sassoulas
Copy link
Member

Type of Changes

Type
🔨 Refactoring

Description

Following a failed attempt to add functional tests for spelling checker in #6137. Branch forgotten for some time but recovered after a global cleanup 😄

@Pierre-Sassoulas Pierre-Sassoulas added Maintenance Discussion or action around maintaining pylint or the dev workflow Skip news 🔇 This change does not require a changelog entry labels Feb 24, 2023
@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@5786d88). Click here to learn what that means.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8338   +/-   ##
=======================================
  Coverage        ?   95.56%           
=======================================
  Files           ?      178           
  Lines           ?    18763           
  Branches        ?        0           
=======================================
  Hits            ?    17930           
  Misses          ?      833           
  Partials        ?        0           
Impacted Files Coverage Δ
pylint/checkers/spelling.py 86.09% <100.00%> (ø)

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the better-name-spelling-checker branch from 4d14d60 to 72de85a Compare February 24, 2023 22:01
@github-actions

This comment has been minimized.

@Pierre-Sassoulas Pierre-Sassoulas changed the title [spelling chacker] Better help message and code organization [spelling checker] Better help message and code organization Feb 25, 2023
@github-actions

This comment has been minimized.

Copy link
Member

@mbyrnepr2 mbyrnepr2 left a comment

Choose a reason for hiding this comment

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

Looks good; couple of observations.

@@ -35,8 +35,11 @@
WikiWordFilter,
get_tokenizer,
)

PYENCHANT_AVAILABLE = True
except ImportError:
enchant = None
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
enchant = None

Does this line serve a purpose anymore now that the PYENCHANT_AVAILABLE is here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's basically so it's defined and we don't get screamed at by linters 😅 The design of this is peculiar, I'm thinking an external plugin would make more sense, because then it could convey in pip metadata that it NEED py-enchant and we could remove all of this. Maybe something to do as a breaking change in 4.0.

enchant.Broker().list_dicts(), pyenchant_available=True
)
else:
pytest.skip("'enchant' is not installed.")
Copy link
Member

@mbyrnepr2 mbyrnepr2 Feb 27, 2023

Choose a reason for hiding this comment

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

Not a big deal but could alternatively use the skipif decorator or something similar to line 34 in the current module.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch, fixed in 8435e2b

def _get_enchant_dict_choices(
inner_enchant_dicts: list[tuple[Any, enchant.ProviderDesc]]
) -> list[str]:
return [""] + [d[0] for d in inner_enchant_dicts]
Copy link
Member

Choose a reason for hiding this comment

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

Is the [""] a default - would this work also? Feel free to leave as-is 🕺

Suggested change
return [""] + [d[0] for d in inner_enchant_dicts]
return [d[0] for d in inner_enchant_dicts] or [""]

Copy link
Member Author

@Pierre-Sassoulas Pierre-Sassoulas Feb 27, 2023

Choose a reason for hiding this comment

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

Yeah, basically an empty dict name means you're not checking anything it's the default value. But when some dict are installed you get a list like ["", "en", "gb"], and you need the empty value.

dicts = "none"
dict_choices = [""]
instr = " To make it work, install the 'python-enchant' package."
def _get_enchant_dicts() -> list[tuple[Any, enchant.ProviderDesc]]:
Copy link
Member

Choose a reason for hiding this comment

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

I was a bit confused by the use of the word dicts while a list of tuples are returned - but this is enchant terminology?

Copy link
Member Author

Choose a reason for hiding this comment

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

enchant.ProviderDesc are the dict, as in an actual dict with word in it, for the spelling check, not a python data structure.

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the better-name-spelling-checker branch from 9aa359d to 8435e2b Compare February 27, 2023 20:25
@github-actions
Copy link
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 8435e2b

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 Skip news 🔇 This change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants