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

Update YAML file to fix Prettier - Issue #498 1st Pull Request #520

Closed
wants to merge 12 commits into from

Conversation

ChasVanDav
Copy link
Collaborator

@ChasVanDav ChasVanDav commented Jan 21, 2025

Description:

On the develop branch, commits cannot be pushed seamlessly due to 'Prettier' formatting that happens after git push attempt.

As per the instructions in Issue #498, I updated the yaml file in order to resolve the issue with Prettier adding a commit after attempting a git push. The goal is for prettier to make its formatting updated alongside the commit process and not inhibit developer from pushing changes in one go.

Changes:

I updated the yaml file by changing the following:
- pre-commit/hooks repository: Update to version v4.4.0, which is compatible with Python 3.8.10.
- pycqa/isort repository: Change from mirrors-isort to pycqa/isort. Update to version 5.10.1, which is compatible with Python 3.8.10.

⚠️ ‼️ Currently running into an issues reinstalling the pre-commit hooks. See the comment below. ⚠️

Next Steps:

Once this branch updates are running smoothly, I will test move on to the next steps entailed in the issue description.

  • "once your branch with upgrade to the file is pushed to remote, create a second new local branch (from develop), document what occurs when you try to add and push changes to that branch
  • merge the remote branch (with the upgraded yaml file) into your new second branch, document what occurs when you try to add and push changes to that branch
  • make another change to your second branch and document what occurs when you try to add and push changes to the branch (we are hoping to see no more formatting changes at this stage)
  • create a third new local branch (from develop), do not make any changes before merging the remote branch (with the upgraded yaml file) into your new third branch, document what occurs when you try to add and push changes to that branch (we are hoping to see no more formatting changes at this stage)"

@ChasVanDav ChasVanDav self-assigned this Jan 21, 2025
@ChasVanDav
Copy link
Collaborator Author

ChasVanDav commented Jan 21, 2025

@daaimah123

I am having an issue with the pycqa/isort update to the yaml file. What I did to try to troubleshoot was clean my pre-commit cache, manually install isort, but they did not clear the error. Do you have any suggestions? I will also drop this in tech-help channel on Slack.

Screenshot 2025-01-21 at 4 41 15 PM Screenshot 2025-01-21 at 4 41 38 PM

When I commented out that particular section of the file, I was able to commit my changes with no problem. Also, I did not run into the Prettier issue!

Screenshot 2025-01-21 at 4 51 50 PM

I got information via the tech-help channel, that this is a known issue with isort.

Screenshot 2025-01-21 at 5 25 26 PM Screenshot 2025-01-21 at 5 25 36 PM

I also looked into the isort documentation and got the following. So, I am thinking that we should delete the seed-isort-config lines from the yaml file.

Screenshot 2025-01-21 at 5 20 40 PM

Following the trail from the previous issue about poetry-core affecting isort, I see just a few weeks ago this update was merged. Shall I change isort version and give it a try?

Screenshot 2025-01-21 at 5 31 05 PM

I updated the version of isort to 5.12.0, but then the Prettier issue came back!

Screenshot 2025-01-21 at 5 35 14 PM

@daaimah123
Copy link
Collaborator

daaimah123 commented Jan 22, 2025

@ChasVanDav It looks like with the update to isort, you resolved the dependency issue/error and are at a clean slate for step one, the original formatting issue this works to investigate resolves the formatting conflicts after updating dependencies, going forward

@ChasVanDav
Copy link
Collaborator Author

The newer version of isort updated should be compatible with Python 3.8.10

Screenshot 2025-01-22 at 9 23 55 AM

@ChasVanDav
Copy link
Collaborator Author

I will explore this solution!

Screenshot 2025-01-22 at 9 31 06 AM

@ChasVanDav
Copy link
Collaborator Author

OMG it worked! I added a post-commit script and that fixed it!
Screenshot 2025-01-22 at 9 49 15 AM
@daaimah123 @monikkaelyse

@ChasVanDav ChasVanDav added dependencies Pull requests that update a dependency file 👩🏽‍💻 returning-grad labels Jan 22, 2025
@ChasVanDav ChasVanDav changed the title Update YAML file to fix Prettier - Issue #498 Update YAML file to fix Prettier - Issue #498 First Pull Request Jan 22, 2025
@ChasVanDav
Copy link
Collaborator Author

ChasVanDav commented Jan 22, 2025

I was having issues with Prettier seeming to be buggy even after the post-commit script. At first there was no post-commit failure, but then it popped up again.

I looked at the Prettier repository that had one more line of code (Exit 0) that the official documentation did not have. I after updating the post-commit script, I was able to commit and push changes without interruption!

Screenshot 2025-01-22 at 12 00 35 PM

@monikkaelyse
Copy link
Collaborator

In regards to pre-commit not automatically staging it's own changes, it appears that this is the intended behavior as allowing anything to automatically commit it's own changes is considered dangerous. You can see more info on this here.

image

I would advise not going against best practices here and although it's annoying to commit again, you should verify that the changes Prettier made were accurate and do not break your code before committing (I've actually had a linter break my code before in Python fyi and it was a nightmare to chase down).

That being said, you can use the Prettier extension to help format your code every time you save so that Prettier won't fail when you go to commit (you can format it it before that point every time you save). More info on that here.

@ChasVanDav
Copy link
Collaborator Author

ChasVanDav commented Jan 23, 2025

As per @monikkaelyse's recommendation, I will move to add instructions to the README file with suggestions on mitigating Prettier's post-commit "issue." It seems like this is normal and best practices for prettier to require a second commit. This pull request should be ready for review by EOD! @daaimah123

@ChasVanDav ChasVanDav changed the title Update YAML file to fix Prettier - Issue #498 First Pull Request Update YAML file to fix Prettier - Issue #498 1st Pull Request Jan 23, 2025
@ChasVanDav
Copy link
Collaborator Author

Closing this pull request and creating new pull request with updated README instructions.

@ChasVanDav ChasVanDav closed this Jan 23, 2025
@ChasVanDav ChasVanDav deleted the issue498-branch1 branch January 23, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file 👩🏽‍💻 returning-grad
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve the "prettier" formatting discrepencies with the pre-commit-config.yaml file
3 participants