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

Imposing "correct" isort as requirement for a green pipeline #73

Merged
merged 20 commits into from
Feb 5, 2024

Conversation

andped10
Copy link
Collaborator

The CI pipeline will now fail if python imports are done "wrongly" according to isort.

The requirements for the isort sorting are defined in pyproject.toml

  • all python files have been sorted accordingly

It is also possible to get the requirements applied on file save in VSCode by using the settings.json file in vscode_template.

To help the user in case of a failing pipeline the following now step echo's a potential resolution to the error. This is not an optimal solution, but it is considered good enough for now.

Bumped:

  • actions/setup-python@v5
  • actions/checkout@v4

Copy link
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

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

The code looks and behaves well but let's have a discussion about standardising items like

  • line width
  • import layout
  • hard failure on static code analysis

if: ${{ failure() }}
run: |
echo "::notice::In project root run 'python.exe -m isort .' and commit changes to fix errors."
exit 1
Copy link
Member

@rozyczko rozyczko Feb 1, 2024

Choose a reason for hiding this comment

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

Is failure the right thing to do? Maybe stylistic issues should only be reported as warnings, like it is done with codecov reports?

original flake8 line for ER has

--exit-zero

so errors are treated as warnings

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can do it differently. The reason why I decided to go for an exit 1 of the echo step is an attempt to make it more obvious that the user might want to consult the produced statement that contains a proposed fix to the issue.

The pipeline itself has already failed in the preceding step.

We should probably discuss.

[tool.hatch.build.targets.wheel]
packages = ["EasyReflectometry"]
[tool.isort]
line_length = 88
Copy link
Member

@rozyczko rozyczko Feb 1, 2024

Choose a reason for hiding this comment

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

This is probably too conservative. With hi res monitors, we tend to write long lines, especially for message formatting.
We specify 120 as the standard max length.
Any good reason to limit the width to 88 (apart from this being the standard in black?)
Likewise, the original flake8 line for this project lists

--max-line-length=127

which, while being inconsistent with the EasyScience standard ( 😅 ) is less restrictive than 88

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was just a value that frequently showed up.

Monkey see, monkey do ;)

@andped10 andped10 merged commit f2c610b into develop Feb 5, 2024
36 checks passed
@andped10 andped10 deleted the 72-isort branch February 5, 2024 05:25
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.

2 participants