-
Notifications
You must be signed in to change notification settings - Fork 152
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
Python files style cleanup #281
Conversation
Thanks a lot for checking over these basics. Is this PR ready for review? We might also want to add a lint / format workflow to check over each of our PRs as a Github Action. I believe it can be done by editing https://github.com/Reckless-Satoshi/robosats/blob/main/.github/workflows/linter.yml . The - name: Run linters
uses: wearerequired/lint-action@v2
with:
black: true
black_dir: api
flake8: true
flak8_dir: api |
Yup, mostly. Just fixing the conflicts and adding the linting action should make it complete. But again, just touched the api/*.py files. You think I should make it complete with running and fixing all the *py files? |
What if in this PR we only merge the changes to We could also edit Next to merging it, I open another PR where I run black for the first time over all of the |
Sounds good. Also I suggest using https://pre-commit.com/ for managing pre-commit git hooks and running things like pretier, flake, black and also maybe running the command to generate the oas schemas automatically as json/yaml and placing them where required, every time someone commits. But this requires the contributors to install and configure pre-commit python package on their systems. Also I have heard real good things about deepsource.io. I wanted to give it a try. It can run those linters and also make commits to fix those linting errors automatically on each PR (will cover people who don't configure pre-commit hooks) |
I'll try including a pre-commit config here as well if you agree on including it... |
That sounds good! Before going into deepsource.io for fixing PR lint errors, we should try to do it with our workflow .github/workflows/linter.yml . I believe it can also be easily configured to run the linters and fix errors on PRs in addition to simply checking. |
Yup it can with linters that support it. Flake8 for instance, doesn't support fixing the issues, but just points it out. There's autopep8 for that I guess. But I don't want to include that, since it's just too much (atleast for now). Another thing to note is that any linting solution (including deepsource) can't actually auto-fix on forked repos, but it should be able to report it? Not sure...will have to test it. |
Also added pyproject.toml for isort config, but later can be used to configure various other python tools
02a69e3
to
bff3929
Compare
Okay, so turns out we can't use either auto-fix or commit annotations using linters. I was hoping the actions ran on each PR touching py files and atleast report the linting errors, so that it can be fixed, but even doing that is tricky. From the readme of wearerequired/lint-action
Even though I am leaving this with the |
6dd43f7
to
9444368
Compare
9444368
to
9398ec7
Compare
Seems like incorporating pre-commit in our dev workflow would be the logical step to enforce the style guides and lint fixes. Will write one up tomorrow, need your inputs for ts/js files. We can still have the above workflows, but only for pushes to main or when you open a PR to main? |
Do we at least get commit annotations if we relax the
|
- name: Run linters | ||
uses: wearerequired/lint-action@v2 | ||
with: | ||
auto_fix: true |
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.
I guess this action will always fail on PRs if auto_fix
is true.
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.
yup, I mentioned it above. It will fail because it won't be able to push commits to forks.
Tried that, didn't work. I am not sure why. Maybe you have to merge this PR first and then test it? |
What does this PR do?
Style clean up using black, isort and flake8
This PR touches only /api/*py files. Not including the sub directories (eg
/api/lightning
, etc). Will be appropriate to take in another PR.I have isolated the changes logically into different commits to make it easier to review by commit.
@Reckless-Satoshi Let me know what you think. We can use this to discuss your gripes with
black
and try to configure it accordingly.Here's a list of PEP8 linting "errors" that were fixed using flake8: