Content-Length: 438378 | pFad | https://github.com/simpeg/simpeg/pull/1134

FD Run style checks in Azure Pipelines by santisoler · Pull Request #1134 · simpeg/simpeg · GitHub
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

Run style checks in Azure Pipelines #1134

Merged
merged 17 commits into from
Nov 24, 2022
Merged

Run style checks in Azure Pipelines #1134

merged 17 commits into from
Nov 24, 2022

Conversation

santisoler
Copy link
Member

Run style checks using flake8 and some of its plugins. Add a new
.flake8 configuration file to tweak the style checks. Add a new
check target in the Makefile. Create a new pipeline in Azure to
automatically run style checks on every PullRequest. Add new required
packages to environment_test.yml and to a new
requirements_style.txt.

Run style checks using flake8 and some of its plugins. Add a new
`.flake8` configuration file to tweak the style checks. Add a new
`check` target in the `Makefile`. Create a new pipeline in Azure to
automatically run style checks on every PullRequest. Add new required
packages to `environment_test.yml` and to a new
`requirements_style.txt`.
@santisoler
Copy link
Member Author

I expect the style checks to fail big time now, but sets the basis for solving those issues and also choose which style checks we would like to enforce in SimPEG.

One major thing I haven't added is pep8-naming, a package and flake8 plugin that checks that variable, functions and classes names follow PEP8. I wouldn't add it right away in SimPEG since it will complain a lot now, but I'm mentioning it to keep record that in the long run would be nice to have it.

This way they both run in Azure regardless of one of them failing.
@jcapriot
Copy link
Member

jcapriot commented Nov 11, 2022

I'm still surprised there's a Makefile left over in this repo, It is barely used for anything, and there's no compiled codes in here anyways that would make it that necessary.

@jcapriot
Copy link
Member

@santisoler looks like there's an error in the azure-pipelines file with a bad name for the style check stage https://dev.azure.com/simpeg/simpeg/_build/results?buildId=2110&view=results. Probably needs to be renamed "Style_Check". You can always explicitly set it's displayname though.

Using spaces in stage names for Azure pipelines cause errors. Rename it
using camelcase instead.
@santisoler
Copy link
Member Author

I'm still surprised there's a Makefile left over in this repo, It is barely used for anything, and there's no compiled codes in here anyways that would make it that necessary.

I saw @rowanc1's hand in that Makefile. I imagined it's not being heavily used in SimPEG. I usually love to see a Makefile in the repo (even if the repo doesn't involve compilation steps) because it provides an easy way to standardize processes, document them and make them quickly available. For example, instead of adding instructions in the README or in the Contributors Guide on how to run every style check, one could just say "run make check". We use this approach in every Fatiando package (see https://github.com/fatiando/verde/blob/main/Makefile) and we use them in our Contributing Guidelines. One can also use it in CI to run tests and code styles (like I'm doing here). So if you want to change something about how the code style gets done, you just need to edit the Makefile and leave the azure pipeline file intact.

@jcapriot
Copy link
Member

We probably want to (for now) allow these tests to fail and still continue with unit tests.

@@ -36,3 +36,10 @@ dependencies:
- pyvista
- pip
- python-kaleido
# Linters and code style
- black
Copy link
Member

@jcapriot jcapriot Nov 14, 2022

Choose a reason for hiding this comment

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

make sure that this version matches the version in the .pre-commit.yml file. (I think 21.7b0)

Pin the version of Black on environment_test.yml and
requirements_dev.txt so it matches the one pinned in the pre-commit
configuration file.
- flake8-bugbear
- flake8-builtins
- flake8-mutable
- flake8-rst-docstrings
Copy link
Member

Choose a reason for hiding this comment

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

we might also want to use flake8-docstrings for numpy style documentation checking
https://pypi.org/project/flake8-docstrings/

@santisoler
Copy link
Member Author

We probably want to (for now) allow these tests to fail and still continue with unit tests.

Sure. Let's just merge this PR and fix all the style issues in separate PRs.

@rowanc1
Copy link
Member

rowanc1 commented Nov 15, 2022

Looks like the make graphs is still in there as well, which made some figures for various papers about the inheritance structure. Exciting to see these new improvements!!

@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Merging #1134 (7f80996) into main (1580c63) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1134   +/-   ##
=======================================
  Coverage   80.07%   80.07%           
=======================================
  Files         137      137           
  Lines       20958    20958           
=======================================
  Hits        16783    16783           
  Misses       4175     4175           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@santisoler
Copy link
Member Author

Thanks @jcapriot for all the changes. I just grouped the target files into a single variable in the Makefile to avoid repetition and to make it easier to change in the future. Feel free to revert it if you don't like it. From my point this PR is ready, so merge it whenever you feel the same.

@jcapriot
Copy link
Member

Awesome, I think the only thing that looks obvious to turn off is the documentation style checking in tests

@santisoler
Copy link
Member Author

Awesome, I think the only thing that looks obvious to turn off is the documentation style checking in tests

Makes sense. We'll never render docstrings of test functions in Sphinx, so we don't care about their format, they just need to be informative when reading them in plain text.

The pinned version of Black is not compatible with latest version of
click, so we need to pin it as well.
Black handles that in its own way and conflicts with what flake8
complains about.
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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/simpeg/simpeg/pull/1134

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy