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

[ci] Introduce typos pre-commit hook #6564

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

borchero
Copy link
Collaborator

@borchero borchero commented Jul 21, 2024

While scrolling through the codebase, I noticed a few typos so I thought it would make sense to rectify them.

To do so, I added a new pre-commit hook, namely typos. typos is a spellchecker that minimizes the number of false positives by maintaining a list of known typos rather than a dictionary of known words.

typos can further be configured in the .typos.toml file where false positives can be rectified, either by extending the list of "identifiers" or "words" that are actually not typos as maintained by the typos tool (loosely speaking, an "identifier" is anything that would be a valid variable name in e.g. Python while a "word" are the individual parts of camel-cased/snake-cased/... names). For instances where the notion of "identifiers" and "words" is insufficient (e.g. for URLs with apparent typos), a list of regexes of strings to ignore can be added.


Apart from the changes to .pre-commit-config.yaml and the creation of .typos.toml, the changes in this PR merely fix the typos uncovered by the typos pre-commit hook.


The only publicly-facing change is the renaming of lgb.interprete to lgb.interpret in the R API. I'm unsure whether this change would be desired.

@borchero borchero changed the title [style] Introduce typos pre-commit hook [ci] Introduce typos pre-commit hook Jul 21, 2024
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

Wow nice! I went through all of these changes and agree with almost all of them. This caught a lot of issues, really nice!

I support adding this to the pre-commit config. Let's see how it goes.

The only publicly-facing change is the renaming of lgb.interprete() to lgb.interpret() in the R API. I'm unsure whether this change would be desired.

Yeah, please do revert these. I don't support breaking user code just to fix this typo. That function has been a part of the public API for several years.

R-package/cran-comments.md Outdated Show resolved Hide resolved
Comment on lines +11 to +13
- [macOS](https://docs.docker.com/docker-for-mac/install/)
- [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
- [Windows](https://docs.docker.com/docker-for-windows/install/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- [macOS](https://docs.docker.com/docker-for-mac/install/)
- [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
- [Windows](https://docs.docker.com/docker-for-windows/install/)
* [macOS](https://docs.docker.com/docker-for-mac/install/)
* [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
* [Windows](https://docs.docker.com/docker-for-windows/install/)

Was this particular change actually the result of the typo pre-commit hook somehow? Or did your local editor settings do this?

Unless this is necessary to satisfy any of the project's linters, or unless it improves the rendering somehow, could you please revert them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was my local editor, reverted!

Copy link
Collaborator

Choose a reason for hiding this comment

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

No problem, thanks.

reverted!

Did you forget to push a commit? This is still showing up in the diff.

docker/README.md Show resolved Hide resolved
@borchero borchero requested a review from jameslamb July 22, 2024 12:29
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

Thanks very much, happy to try this! Please just see 2 more small comments... I think maybe you forgot to push a commit.

Comment on lines +11 to +13
- [macOS](https://docs.docker.com/docker-for-mac/install/)
- [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
- [Windows](https://docs.docker.com/docker-for-windows/install/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

No problem, thanks.

reverted!

Did you forget to push a commit? This is still showing up in the diff.

docker/README.md Show resolved Hide resolved
@StrikerRUS
Copy link
Collaborator

The only publicly-facing change is the renaming of lgb.interprete to lgb.interpret in the R API. I'm unsure whether this change would be desired.

I think we should mark lgb.interprete as deprecated and remove it in a next release.
Under the hood lgb.interprete should call lgb.interpret for now.

[default.extend-words]
MAPE = "MAPE"
datas = "datas"
interprete = "interprete"
Copy link
Collaborator

Choose a reason for hiding this comment

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

LGTM except leaving "interprete"!
See #6564 (comment) for my proposal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use this thread to discuss that proposal.

Please remember that breaking the public API of an R package is more difficult than doing it for a Python package, because of CRAN's restrictions.

CRAN will check the "strong reverse dependencies" (anything including lightgbm in LinkingTo, Depends, or Imports, I think) and check if a new submission breaks any of their builds or tests. This is why for the v4.0.0 release, I went around to all the packages listed at https://cran.r-project.org/web/packages/lightgbm/index.html as depending on {lightgbm} and made contributions to make them compatible with both v3.x and v4.x of {lightgbm}.

HOWEVER.... it does not look like any package on CRAN is using lgb.interprete(): https://github.com/search?q=org%3Acran%20%22lgb.interprete%22&type=code

So I'm ok with @StrikerRUS 's proposal, which is:

  • introduce a new function lgb.interpret() which just calls lgb.interprete()
  • raise a deprecation warning in direct calls to lgb.interprete()
  • eventually remove lgb.interprete()

@borchero if you are not comfortable making those R changes (like updating the NAMESPACE file or writing roxygen comments), let me know and I can do this in a follow-up PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remember that breaking the public API of an R package is more difficult than doing it for a Python package, because of CRAN's restrictions.

Ah, to be honest, I forgot about this!

HOWEVER.... it does not look like any package on CRAN is using lgb.interprete()

Thank God! 😃

Copy link
Collaborator

Choose a reason for hiding this comment

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

@borchero can you please return to this?

Just revert everything about lgb.interprete and we can talk about it in a separate issue. All of the other changes are non-controversial and I'd like to get this typo hook running in pre-commit to help with other development.

@StrikerRUS
Copy link
Collaborator

@jameslamb

Yeah, please do revert these. I don't support breaking user code just to fix this typo. That function has been a part of the public API for several years.

Sorry, haven't noticed your comment from the first glance!

WDYT about the following #6564 (comment)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants