-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[spelling checker] Better help message and code organization #8338
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8338 +/- ##
=======================================
Coverage ? 95.56%
=======================================
Files ? 178
Lines ? 18763
Branches ? 0
=======================================
Hits ? 17930
Misses ? 833
Partials ? 0
|
4d14d60
to
72de85a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enchant = None |
Does this line serve a purpose anymore now that the PYENCHANT_AVAILABLE
is here?
There was a problem hiding this comment.
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.
tests/checkers/unittest_spelling.py
Outdated
enchant.Broker().list_dicts(), pyenchant_available=True | ||
) | ||
else: | ||
pytest.skip("'enchant' is not installed.") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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 🕺
return [""] + [d[0] for d in inner_enchant_dicts] | |
return [d[0] for d in inner_enchant_dicts] or [""] |
There was a problem hiding this comment.
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]]: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Following a failed attempt to add functional tests for spelling checker in pylint-dev#6137
9aa359d
to
8435e2b
Compare
…ylint-dev#8338)" This reverts commit 5e0223b.
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 8435e2b |
Type of Changes
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 😄