-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add first version of pre-commit #153
Add first version of pre-commit #153
Conversation
@isteinbrecher this would be ready for review This PR introduces the first version of a more exhaustive pre-commit hook for MeshPy - and simply executes it in the check-code action
In the future I see a few small improvements which I did not want to add to this PR to not add to many changes
A pre-commit hook now looks like this
|
b457ee1
to
5ff490c
Compare
I've now also changed the I've also changed the |
Thanks a lot @davidrudlstorfer for these changes! I will have a look, but it might take until next week. Regarding your questions:
Sounds good to me
Sounds good to me
I would like to see how that looks like, but in general I am for something like this
I remember we talked about this and you mentioned, that this only makes sense if it is done throughout the code base (and type are also enforced?). I am for adding type hints (the
We already have that, the test |
And yes, the default ubuntu image is fine for the code checks |
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.
Thanks a lot @davidrudlstorfer for taking a look into this, this will definitely put the code quality of MeshPy to another level. I left some comments regarding the configuration. I have two more questions:
- Is it possible to have one commit that applies all the automatically done stuff and one that adds the manually required changes for everything to pass?
- For practical purposes, if I want to commit something and I get an error message in the pre commit hook, do I get a command that I can use to apply the suggested changes or are they applied automatically, how does that work?
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.
Thanks a lot @davidrudlstorfer for taking a look into this, this will definitely put the code quality of MeshPy to another level. I left some comments regarding the configuration. I have two more questions:
- Is it possible to have one commit that applies all the automatically done stuff and one that adds the manually required changes for everything to pass?
Unfortunately, I've combined both changes into a single commit and I would prefer not to split them up again as it was a lot of manual work 🥶 if you're ok with it I would leave it as is
- For practical purposes, if I want to commit something and I get an error message in the pre commit hook, do I get a command that I can use to apply the suggested changes or are they applied automatically, how does that work?
That depends on the specific hook - all formatting changes are applied completely automatically if they fail, i.e., formatting any sort of code (C++, Python) or formatting docstrings.
Code related problems are not automatically adjusted - there the user has to intervene manually, i.e., mypy
and bandit
and the tools provide an error where type problems may arise or sometimes also show one or more solutions on how to solve the problem
a29da58
to
98abcd3
Compare
Thanks for the explanations @davidrudlstorfer. I tried to "split" your first commit by first applying just the automatic changes from the pre-commit hooks and then resetting the state to your commit, I think that should have worked (see the branch on my fork https://github.com/isteinbrecher/meshpy/tree/add_pre_commit_hook). Can you have a short look if those are your manual changes (in the commit 16253c4) and if so push that commit structure to this PR? (The actually code in the final state is exactly the same). |
98abcd3
to
38d448e
Compare
38d448e
to
b461567
Compare
b461567
to
f53cc47
Compare
@isteinbrecher I've now rebased everything onto main - as there were also some changes which were necessary to the cosserat module. I've also split up everything into logical commits and also split the automatic and manual changes as you suggested. I encounter one problem which I was not able to solve directly - maybe you could have a brief look: The code check now fails with a problem in the new cosserat module: meshpy/cosserat_curve/cosserat_curve.py:391: error: Unsupported operand types for <= ("list[float]" and "float") [operator]
meshpy/cosserat_curve/cosserat_curve.py:393: error: Unsupported operand types for >= ("list[float]" and "float") [operator]
meshpy/cosserat_curve/cosserat_curve.py:398: error: Unsupported operand types for - ("list[float]" and "float") [operator] (see actions output) Unfortunately, I was not able to quickly test this behaviour as it was not triggered within the testing pipeline (I simply wanted to exit once this part is reached) Is this really wrong code or is there another problem here? EDIT: It is tested 🤦🏻 I did not use |
ad3c25f
to
f53cc47
Compare
@isteinbrecher so the problem within the cosserat curve was that the variable arc_length was previously initialized as a list, then reset to a float. MyPy uses the first initialisation of a variable => therefore it was wrong if you are happy with these changes I would combine the last two commits into the manual changes |
c652092
to
e143551
Compare
I adapted the changes in |
I will have a look at the other changes now, I think it is best if we combine the commits once everything is resolved. |
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.
Thanks a lot @davidrudlstorfer for the effort put into this. I really like the new look and feel. I had a look at all the changes, and adapted the ones where I had some issues directly - now I am asking for your review on those. If you agree with them, I think we can squash the relevant commits together and merge this!
@isteinbrecher also big thanks to the effort you put into the review 🙏🏻 I think this lays a good foundation to further improve the code quality within the repo and for future work. Thanks for improving the manual code changes necessary to comply with the new pre-commit hook and associated changes. From my side everything is alright. As a last step I would squash the last 6 commits into the manual changes and then I would be happy to merge 🚀 |
9692a95
to
b91dfcd
Compare
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.
Thanks again @davidrudlstorfer! Let's get this merged, great to see MeshPy improving!
@isteinbrecher unfortunately you have to merge as I am unable to merge 😅 |
One thing I just saw in the test report, we don't actually check any
all the |
Add first version of more exhaustive pre-commit hook