-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Adding configuration for pre-commit #190
Conversation
I think this makes sense for users or organizations that want such behavior. As things currently are, contributors of this project go through CI which tests spelling already. While I won't say I never commit directly to main 😏, I usually go through the same PR process. I currently find this sufficient. If I had multiple core maintainers, and I allowed them all to push directly to main, I can see where requiring a commit hook would make more sense. So as things currently stand, the git hook would probably just slow me down and not offer anything that I'm not already getting from CI. I do think such a suggestion is helpful for the right projects where something like this needs to be more strongly enforced. |
I just wanted to add it to my very own The After all, Please don't confuse the The former,
I thought it doesn't hurt to add it, since it is basically no maintenance whatsoever, but eases the initial usage when you'd like to use it without setting up your own virtual environment ( I initially planned to simply create a repository which provides the Sure, I can copy the I hope I explained a little better what I had in mind when proposing this PR. |
I'm not sure I understand. You've committed a pre commit yaml config to this project, but most people will install through pypi, so how will they get your config? I don't often use such functionality, so forgive me if I seem a little clueless on this topic. |
No worries at all. Let me try to explain it a little better. All It creates a virtual environment to install the application to run before committing code. In this case that's The file I introduce with this PR is the definition of how To utilize this, users have to create a Should you merge this PR and build a new version, I'd update my - repo: 'https://github.com/facelessuser/pyspelling'
rev: 'v2.11'
hooks:
- id: 'pyspelling'
name: 'pyspelling' This has the benefit that whenever you release a new version of Former, existing and future users and maintainers of I hope I did a better job this time of explaining it. |
Your referencing the repo directly, not installing through PyPI? Usage outside of PyPI, well not prohibited, is not quite how this tool is designed and maintained to be used. |
It is ultimately installed through |
Right, but you have to reference the repo to get it, not the pip installed package it seems. Also, there seems to be nothing in the config that is release dependent, so why is it better for us to provide it instead of you defining it in your repo? |
The command that is run by
This way it retrieves the requirements/dependencies of
If I define it "locally" in my repository, I need to keep up with the changes of Creating my own repository to provide merely this hook configuration has the same culprit, as I need to provide If it's part of a release of Does that clear things up? |
The PyPI package, from pip, does not include the hook. It will not be in the wheel. I don't quite understand how you are using the project, but I think you are doing something extra here. Again, there appears to be no release dependent info in the config either, so I also still don't understand why it needs to be included in PySpelling directly. |
That's absolutely correct. What
I don't have the I can also list you a few projects that make use of it exactly like that: There are many more; These are just the ones I use. I think we are running in circles. If you'd rather not have the PR merged: Please let me know - all good! 🙂 I'd just like to see |
This helps. Let me look into this more before I come back with a response. |
Okay, I understand a bit better now. Forgive the circles we had to run around, but I have to understand what I am committing to maintain before I opt to do so. I think I'm probably okay with idea of this. Unfortunately, there is still one rub, if we do this, does this mean you are pulling the tip of main all the time? If so, you do so at your own risk as I do not guarantee that you will not have a bug introduced on the tip. Or am I still misunderstanding? If I am correct, then what you may be asking is for me to not only add the hook, but change my current maintenance habits, to develop off main only ( a separate dev branch). That is a bigger ask. |
All good. I just had the feeling you were arguing against the idea - which is perfectly fine. I just wanted to avoid that we are running in circles, without getting to a common understanding.
No, that's not the case, although you could configure The
From my experience most people use option 2: Set - repo: 'https://github.com/facelessuser/pyspelling'
rev: 'v2.11' # this is a hypothetical new release and would refer to git tag v2.11
hooks:
- id: 'pyspelling'
name: 'pyspelling' You are already creating tags using Which brings me to the last quote:
No, you don't need to change your developing habits at all! Let me know if you have any questions or doubts. |
Nope, this clears up everything. I think now that I have an understanding, I am less squeamish about the change. I have not traditionally taken advantage of git hooks in this way, so I really wanted to get a grasp of what I was getting into. With this all sorted and clear, I think I'm okay with this change. |
We would need to note this in the documentation though. |
Sure, I can do that. Where would you like to have that added? |
Maybe in its own section at the bottom of this page: https://github.com/facelessuser/pyspelling/blob/master/docs/src/markdown/index.md. Just an example showing how someone may use it. |
What about something like the following? GitHub kind of messes up the markdown, but I think you get the idea 😅. ## Usage as pre-commit hook
`pyspelling` can be used as [`pre-commit`](https://pre-commit.com/) hook. To use it as `pre-commit` hook, please have a look at the following example `.pre-commit-config.yaml`:
```yaml
repos:
- repo: 'https://github.com/facelessuser/pyspelling.git'
rev: 'v2.11'
hooks:
- id: 'pyspelling'
verbose: true
pass_filenames: true
...
Please note that version tags should be preferred over using the `master` branch as revision (`rev`) attribute, as the `master` branch is considered unstable.
|
If that's fine with you, I'd add this change to this PR. I am also happy to create a new PR for that change. Just let me know how you'd prefer it 🙂. |
I'd do it here. It is all related. I'm fine with the proposed text. Maybe titlecase the title and that should be fine. |
I upper-cased 'hook' but not |
Maybe place it in |
Sure, I hesitated to do so, as some people don't like code blocks in their headings and didn't see it anywhere else in the documentation (on a quick glimpse, however). I'll push an update momentarily. |
I just also saw that you are writing PySpelling rather than |
I don't mind. Code stuff goes in code stuff 🙂. I know even when people do that, they sometimes won't style it as code in titles either, and I say 🤷🏻. |
Sorry for the mess, I just saw I messed up the configuration in the markdown. It is now correct - double checked it.
I see it exactly the same way. Sometimes it looks a little weird, especially when it is only a title with an inline code block, but, hey, code goes into code blocks - no matter what 🤣 |
@gir-bot lgtm |
I don't know if you'd like to entertain the idea, but I thought I'll give it a try.
With this pull request I am adding a hooks configuration for
pre-commit
, which is a widely used tool for configuringgit hooks
.I think it makes a lot of sense to run
pyspelling
before committing code, therefore I'd like to contribute it.Please let me know your thoughts.