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

add isort workflow #1538

Merged
merged 28 commits into from
May 30, 2022
Merged

add isort workflow #1538

merged 28 commits into from
May 30, 2022

Conversation

mirpedrol
Copy link
Member

Attempt to implement isort in CI as mentioned in #1526 comment.
Adds isort to sort and organize python imports as a GH action workflow.

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@codecov

This comment was marked as resolved.

Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

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

Great stuff, thanks for this! What do you think as adding it as a job to the existing lint-code.yml file? As it's conceptually similar (checking code quality).

Also I would expect there to be a bunch of code changes required after adding this? 😅

@mirpedrol
Copy link
Member Author

That's true, I will add it to lint-code.yml instead of creating a new file, thanks!
Should I add the changes in the code after running isort in this same PR?

@ewels
Copy link
Member

ewels commented May 5, 2022

Should I add the changes in the code after running isort in this same PR?

Yes please, as otherwise tests on the repo will immediately start failing 😁 May as well do it all in one..

Note that the CI test should be failing on this PR but isn't: https://github.com/nf-core/tools/runs/6274840729?check_suite_focus=true

Looks like it's changing loads of stuff but then still reporting a ✅

@ewels
Copy link
Member

ewels commented May 5, 2022

Also it looks like jamescurtin/isort-action has been renamed to isort/isort-action

@mirpedrol mirpedrol marked this pull request as draft May 5, 2022 11:49
@fabianegli
Copy link
Contributor

fabianegli commented May 16, 2022

It would be great to have the isort configuration added to pyproject.toml. I would like to see three things specifically, one is the force single line imports another is to have nf_core set as known first party and the last is profile black for compatibility with black.

[tool.isort]
profile = "black"
known_first_party = ["nf_core"]
force_single_line = true

@mirpedrol mirpedrol added the WIP Work in progress label May 17, 2022
.github/workflows/lint-code.yml Outdated Show resolved Hide resolved
.github/workflows/lint-code.yml Outdated Show resolved Hide resolved
.github/workflows/lint-code.yml Outdated Show resolved Hide resolved
nf_core/modules/info.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@mirpedrol
Copy link
Member Author

I don't know why the linting is failing after running isort. It's successful for me locally with isort --check-only --diff . or isort --profile black --multi-line 3 --project nf-core --check-only --diff . but it fails in the GitHub action. Any idea? @ewels @fabianegli

I also added isort to fix-linting.yml, it works locally with act, but I don't fully trust it. I guess it can't be tested before based on this

This should be ready for review once I solve the linting error here :)

@ewels
Copy link
Member

ewels commented May 20, 2022

I'm getting more tempted to use precommit... 👀

@fabianegli

This comment was marked as outdated.

@fabianegli

This comment was marked as outdated.

mirpedrol and others added 2 commits May 24, 2022 15:59
Co-authored-by: Fabian Egli <fabianegli@users.noreply.github.com>
Co-authored-by: Fabian Egli <fabianegli@users.noreply.github.com>
Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

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

Looking good! Please can you add some docs about how contributors can run this locally before pushing etc?

@fabianegli
Copy link
Contributor

+1 For documenting how to run isort locally. (I think at some point we might want to provide .pre-commit-hooks for convenience, but I see that as a separate issue from adding isort linting.)

I think the docs can just mention running isort . in the top level directory of the tools git repo and link to https://pycqa.github.io/isort/index.html for further reference.

@mirpedrol
Copy link
Member Author

Please can you add some docs about how contributors can run this locally before pushing etc?

I am not sure on the best place to add the documentation. Would you be OK with adding a new section "Contributing" and "Code formatting" to the README?

@fabianegli fabianegli self-requested a review May 25, 2022 08:48
@fabianegli
Copy link
Contributor

fabianegli commented May 25, 2022

There's also a possibility to create a specific place for developer documentation, e.g. a CONTRIBUTING file like the one in biopython. I would say the README is fine though. But I wonder what @ewels thinks?

@ewels
Copy link
Member

ewels commented May 25, 2022

You mean like this? 😉 https://github.com/nf-core/tools/blob/master/.github/CONTRIBUTING.md

It shows up as a hint when you open issues and PRs but yeah, we should probably move out into the root and mention it in the readme to make it more findable.

@fabianegli
Copy link
Contributor

I made a new issue for your proposals and think for this PR the docs can simply be added to .github/CONTRIBUTING.md

.github/CONTRIBUTING.md Outdated Show resolved Hide resolved
@fabianegli
Copy link
Contributor

fabianegli commented May 25, 2022

for black, there's no effect description in the dev-docs, and I think its not necessary. I also think it is not necessary for the isort. It just does its thing. If it needs to be desribed, I would go with something like this: "isort separates imports into sections by origin (builtin > third party > first party) and within the sections by type (import > import from) and within type alphabetically." but that still doesn't capture the indentation for multiple imports... so I would just skip that.

mirpedrol and others added 3 commits May 25, 2022 12:17
Co-authored-by: Fabian Egli <fabianegli@users.noreply.github.com>
@mirpedrol mirpedrol removed the WIP Work in progress label May 30, 2022
@mirpedrol mirpedrol requested a review from ewels May 30, 2022 12:49
@ewels ewels merged commit f63df8c into nf-core:dev May 30, 2022
@ewels
Copy link
Member

ewels commented May 30, 2022

Great stuff @mirpedrol 👏🏻 Thank you!

@fabianegli
Copy link
Contributor

Thank you @mirpedrol
It's so nice to have isort integrated handling the imports 😍

@mirpedrol mirpedrol deleted the isort branch June 2, 2022 13:35
This pull request was closed.
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.

3 participants