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

Setup pre-commit with useful plugins #85

Merged
merged 2 commits into from
Apr 1, 2024
Merged

Setup pre-commit with useful plugins #85

merged 2 commits into from
Apr 1, 2024

Conversation

jcpunk
Copy link
Contributor

@jcpunk jcpunk commented Mar 22, 2024

This adds support for pre-commit to the repo which can greatly simplify consistent code practices.

Copy link
Collaborator

@DrDaveD DrDaveD left a comment

Choose a reason for hiding this comment

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

The new pre-commit check fails.

What was the inspiration for this?

@brianhlin
Copy link
Member

I've always wanted to play around with pre-commit and black but have always been hesitant because I haven't gone through the trouble of making sure black doesn't royally screw up git blame. If we address that and make sure that we still support Python 3.6, I could be open to this.

@brianhlin
Copy link
Member

Oh and I missed that you're using the pre-commit action,

this action is in maintenance-only mode and will not be accepting new features.

generally you want to use pre-commit.ci which is faster and has more features.

@bbockelm
Copy link

@brianhlin - you want https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view .

And yes, precommit tries to bump you to their CI. I tend to just ignore that.

@jcpunk
Copy link
Contributor Author

jcpunk commented Mar 24, 2024

The new pre-commit check fails.

What was the inspiration for this?

If you're interested in going with these tools, some automation to keep folks in sync is usually helpful.

@DrDaveD
Copy link
Collaborator

DrDaveD commented Mar 25, 2024

We can't use it if it fails the check. Do you plan to fix it?

The tools in this package are quite small and hardly seem worth spending much effort on.

@jcpunk
Copy link
Contributor Author

jcpunk commented Mar 25, 2024

Fixing the check is trivial; I can get that done if this is a direction folks are interested in.

@DrDaveD
Copy link
Collaborator

DrDaveD commented Mar 25, 2024

I think that as long as you've done the work we might as well include it. It sounds like the Brians are in favor too.

@jcpunk jcpunk requested a review from DrDaveD March 25, 2024 22:12
@jcpunk
Copy link
Contributor Author

jcpunk commented Mar 25, 2024

float_to_top = "True"

Might need to be removed because of osg-cert-request and osg-incommon-request depending on how you're calling them.

I'd be tempted to use entrypoint: [console_scripts](https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html) to generate them more dynamically.

@brianhlin
Copy link
Member

@jcpunk can you add a .git-blame-ignore-revs file including bced63736532f958c7dd1c12a36b042074bfad70?

@DrDaveD
Copy link
Collaborator

DrDaveD commented Mar 26, 2024

float_to_top = "True"

Might need to be removed because of osg-cert-request and osg-incommon-request depending on how you're calling them.

What do you mean? What type of way of calling them would be tripped up by float_to_top = "True".

I'd be tempted to use entrypoint: console_scripts to generate them more dynamically.

How does that help?

@jcpunk
Copy link
Contributor Author

jcpunk commented Mar 26, 2024

What do you mean? What type of way of calling them would be tripped up by float_to_top = "True".

It looks like the scripts are expecting to adjust sys.path before finishing the imports. With float_to_top = True the isort tool will move all the imports to the top of the scope. This may not be what you're expecting for these scripts.

The setuptools console_scripts will generate these "/usr/bin/" scripts dynamically so you don't need to write/maintain/separate these out. Use of these setuptools hooks should in theory reduce your long term burden. We've had good success with those in the HepCloud DecisionEngine.

@jcpunk
Copy link
Contributor Author

jcpunk commented Mar 26, 2024

Added the ignore revs file

@brianhlin
Copy link
Member

@jcpunk it looks like those Python path hacks are just that, hacks to make unit testing happy and to make life easier when running in a virtualenv. I would definitely like both to continue working so if you've got alternate suggestions for those use cases, I'm all ears!

@jcpunk
Copy link
Contributor Author

jcpunk commented Mar 29, 2024 via email

@brianhlin
Copy link
Member

In that case, I'm happy with this unless @DrDaveD has any other thoughts

Copy link
Collaborator

@DrDaveD DrDaveD left a comment

Choose a reason for hiding this comment

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

Looks OK to me

@brianhlin brianhlin merged commit b80a415 into opensciencegrid:master Apr 1, 2024
6 checks passed
@jcpunk jcpunk deleted the pre-commit branch April 1, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants