-
Notifications
You must be signed in to change notification settings - Fork 71
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
Allow for use of styler via python pre-commit without R package {precommit} #662
Comments
Hi @stefanoborini, |
@lorenzwalthert What I mean is that there's no pre-commit-hooks file definition in styler. To get the hooks, you need to install the precommit R package. |
You mean in this GitHub repo? Can you be more specific about which file you are refering to? The hook definition is hosted in https://github.com/lorenzwalthert/precommit, in the file |
I don't want to install precommit R. It brings in a lot of other dependencies I am not willing to provide in my environment, and in fact it does not work if I don't have some packages. I want just to use styler with pre-commit (the python utility)
Why would I need to add things I am not interested in? I just want to use styler.
the hooks in pre-commit-hooks on precommit (r package) are here https://github.com/lorenzwalthert/precommit/blob/master/.pre-commit-hooks.yaml They provide roxygenize, styler, and many other things. I want to use only styler, and I don't want to install precommit (r package) in my environment to either deploy the hooks. In fact, when I tried, I got an error about docopt missing
The reason is probably that I don't have docopt in my environment, and I don't want it. I have no idea what is using docopt, but styler is definitely not using it.
|
I know, I created this (and the majority of styler).
Then install the python utility with one of the installation methods described in the README of lorenzwalthert/precommit and add the styler hook to your config file. Then, in the
Then run
Because in your config, there are all the hooks that you said you don't want to use 😄 |
I want just to use styler with pre-commit (the python utility)
This is exactly what I have done.
And that's my point. Why do I have to install docopt as a dependency in my R environment for hooks that come from precommit (r package) which I am not going to use? If I need to only use styler, I need a hook in the styler git repo, point to that repo, install styler in my R environment, and have styler do its job, without any need for docopt. My config is literally the one I gave above. It only contains the style-files id. Nothing else. |
Just for curiosity, what is the entity that is requiring docopt in order to run? |
I am sorry but I was wrong, docopt is used in the styler hook to parse command line options. It's the only dependency you need here and it has 0 non-base reverse dependencies. |
I think we can close this, feel free to re-open if necessary. |
@lorenzwalthert Depends. Is it fixed? I still would prefer not to install a secondary package that has nothing to do with it. I see no logical reason to do so. |
I don't plan remove the docopt dependency if that's the question. |
No, that's not my question. docopt is a dependency of styler (but if that's the case, it should probably be advertised in the DESCRIPTION file, as it is not at the moment). My point is that I don't want to install the precommit R package so that I can use styler with pre-commit. |
docopt is not a direct dependency of styler. You can see it in the DESCRIPTION file of styler. A package that does not list a dependency in DESCRIPTION will fail R CMD check and therefore won't ever be released on CRAN. As pointed out above, docopt is a dependency of the hook script the python pre-commit framework will run when you invoke |
I understand. You should move the hook script here and put the dependency docopt here. That is the whole point of the initial issue. docopt slipped in during the discussion. It is pointless to install a separate package (precommit, the R package) to use this one! |
As previously discussed, you don't need to install the R package {precommit} to run the hook. You need all the packages installed globally that are required by the hook script, which for the styler hook is docopt and styler. There is no dependency management for R hooks because R is not (yet) an officially supported language in the pre-commit framework so you need to install them manually as descrbied in https://github.com/lorenzwalthert/precommit#caution.
We could move the hook scripts here but I prefer not to. It does not matter actually where they live for the end user. Why should I require people to install docopt if they don't want to use the hook? 99% of people actually don't user the styler as a pre-commit hook, they use it in other ways (Addin, R API). |
If I want to use styler and only the styler hooks, I don't want to be forced to install precommit, which includes a lot of other stuff. I should be able to have plain styler and add only its hooks.
The text was updated successfully, but these errors were encountered: