-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add pre-commit config and a new workflow to run the pre-commit hooks on any PR #503
Conversation
Just so you know we dont need a separate Feel free to close it if the feature is not desired for now:) |
Hey @thesujai, thanks for your contribution! I'm curious about why |
backend/dev-requirements.txt
Outdated
pre-commit==2.20.0 |
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.
Should probably bump up the pre-commit here as well
One of the checks failed. Interesting. |
Hi @jayantbh thanks for a quick review
But flake8 will throw an F401(Imported but not used) as the os module is imported but never used.
Yes, it is supposed to fail, I just introduced it with this PR. It will pass once I push all the formatted files(formatted by the pre-commit hooks). I am not pushing now as reviewing would be really irritating with so many lint-fixed files |
Sounds good. I'd like @samad-yar-khan and @adnanhashmi09 to confirm if |
I am just bad with explaining my thoughts More like having flake8 along with black(as black is just the formatter, flake8 is just a checker). But both of these we will have as pre-commit hooks(with the pr introduces). Just the thing to remove will be the black github action, as black will be ran as the last hook of pre-commit with the new pre-commit workflow. |
@thesujai there's a conflict, and a failing lint test. |
fdd7df2
to
bcc10e7
Compare
@jayantbh It should work now. I rebased it with main. Any changes in the upstream will again make the workflow to fail if this gets merged, so we have to make sure this is up to date with main before it is merged(it is now!) |
Hey @thesujai, this PR is currently on pause because we're waiting for some other PRs to get merged to avoid rework on them. We'll take it up again in 1-2 days. |
Hey @thesujai, could you resolve the conflict on this? |
bcc10e7
to
b670cb0
Compare
@jayantbh Shall work now |
Added the related docs as well(Pardon the grammar there 🙃 ) |
Thanks! I've triggered the workflows. |
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.
- why are SVGs also being linted? What is the reasoning behind it.
- There are a lot of places in the python code where flake8 is being suppressed. Why?
Most probably they didn't have the extra blank line at the eof. |
Most probably they didn't had the extra blank line at the eof.
Mostly I am doing to ignore the warning when we use |
@thesujai Got it. Thanks for the clarifications. We should have a followup PR to have these comments removed. But for now it looks good to me. |
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.
LGTM
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.
Screen.Recording.2024-08-29.at.1.37.04.PM.mov
So, it tells me whats wrong but shouldn't the precommit hook fix these for me ?
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.
Pls update the doc as mentioned above + check if the precommit can lint code on its own.
Preferably, if someone is using /.dev.sh for dev, they are looking to change the code. See if we can get them to install the precommit at the top rather than potential misses and a lint commit at the end when they discover the precommit hook
I can add |
I missed this, but yeah a linter should absolutely try to fix as many issues automatically as it can. |
I don't understand what you trying to say here. Let me know if the latest commit solves your concern! |
Hey @thesujai , that last commit solves a part of the problem of automatic linting with pre-commit hook. This still does not solve the effort of manually installing python dependancies just to run the precommit hook. |
@samad-yar-khan I updated the PR |
Was previously using 18, now using 16.19.1 |
From here it looks like your We can configure dev.sh to also install the node_moduels(locally, not in a docker container), but this would mess up the current workflow where node_modules are getting installed into docker containers. I suggest doing this but only adding eslint(and other linting tools) to the dev.sh workflow that will install node_modules(only with required tools) locally. But this would be extra work to keep maintaining the tools versioning in package.json as well as the dev.sh script. Let me know if you have other ideas. How I like to view things is that development is one thing and contributing is another. |
I don't like where this is headed, installing node_modules and python dependencies on both the container and the host machine. This kind of defeats the purpose of having a development setup with containers in the first place. Can't we just use docker volumes to map the node_modules and python dependencies to the host's filesystem? |
Possible, but there are some tradeoffs:
|
Yeah makes sense. To run the linting process we would have to install node_moduels and python dependencies anyhow. Maybe we could remove it from the dev process and add to the contributing docs. This is making things a little messy in my opinion. @jayantbh Thoughts? |
@thesujai I'd say let's remove the installation of linters from the dev process and make this a part of Sorry for the slight rework on your end and thanks for your inputs! |
…h cli and webserver
b59f70c
to
2672e6e
Compare
Clean now, rebased with main branch as well |
CONTRIBUTING.md
Outdated
|
||
## Making Commits | ||
|
||
1. Pre-commit should be installed as a dev dependency already. If not then Create a virual environment [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) or [pyenv](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) and run the follwoing command from project root dir: |
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.
1. Pre-commit should be installed as a dev dependency already. If not then Create a virual environment [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) or [pyenv](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) and run the follwoing command from project root dir: | |
1. Pre-commit should be installed as a dev dependency already. If not then Create a virual environment [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) or [pyenv](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) and run the following command from project root dir: |
CONTRIBUTING.md
Outdated
yarn add eslint@^8.40.0 eslint-config-next@13.5.6 eslint-plugin-import@^2.29.0 eslint-plugin-prettier@^5.0.1 eslint-plugin-react@^7.29.4 eslint-plugin-unused-imports@^3.0.0 --dev | ||
``` | ||
``` | ||
cd webserver |
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.
cd webserver | |
cd web-server |
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.
Ah good catch!
CONTRIBUTING.md
Outdated
cd cli | ||
yarn add eslint@^8.40.0 eslint-config-next@13.5.6 eslint-plugin-import@^2.29.0 eslint-plugin-prettier@^5.0.1 eslint-plugin-react@^7.29.4 eslint-plugin-unused-imports@^3.0.0 --dev |
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.
No need to install eslint-config-next
for cli as it doesn't depend on nextjs.
@adnanhashmi09 should 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.
LGTM🚀
It would have been great to lint files inside the container itself, without having the developer worry about linting. But, it's good for now. I will look into a possible solution and if found, will take it up in another PR.
Thanks for the contribution @thesujai. Much appreciated!
Amazing. This was a trip. 🚀🚀🚀 |
Linked Issue(s)
Closes #502
Acceptance Criteria fulfillment
Proposed changes (including videos or screenshots)
yarn lint
resulted in nothing because paths were not configuredFurther comments