-
Notifications
You must be signed in to change notification settings - Fork 317
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
chore: reformat codebase with longer line length #2362
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2362 +/- ##
========================================
Coverage 74.1% 74.2%
========================================
Files 292 292
Lines 59476 59622 +146
========================================
+ Hits 44127 44261 +134
- Misses 15349 15361 +12
|
I'd vote for the default 88. And there may be other commits in the history we might want to apply This triggered a lot of codacy warnings for some reason, maybe things that it missed before? A lot can be ignored but a few look like real issues |
I like the idea of switching to the default of 88. The resulting code is easier to read. Will need to update the create packages code, but that can be done separately as it is currently under development. |
I also like the line length limit of 88. While we’re on this topic, I think it could be beneficial (and in the same spirit of this PR) to review the other Ruff settings as well, particularly the linting rules that are currently set to be ignored. |
Agreed, we ignored several to make the initial move to ruff easier but imo it makes sense to aim for the defaults. Maybe we can add |
d4e75c0
to
5307a9f
Compare
Agree that the default 88 char length looks ideal, so let's keep it. I've revised this PR to exclude As for enabling some other Ruff checks, agree this is a good idea, but I recommend to choose these carefully with individual PRs with specific aims/fixes. |
rebasing after #2363 should turn codacy green here |
Codacy began detecting a "severe" pylint E1126 invalid sequence index violation in #2362. The issue pre-existed that PR, I think the format changes just revealed it. We could just ignore it in the web UI but this is probably worth coming back to, to appease linters and type checkers and to make the code easier to reason about. Relatedly, there is work ongoing to make ruff work with codacy, so hopefully in future we can use ruff ignore syntax for things like this if/when needed
5307a9f
to
3af2e20
Compare
This PR reformats Python code with a maximum line length of 88 characters to better represent the code. Note that a related repo MODFLOW-USGS/modflow6-examples already uses the default line length of 88. See modflowpy/flopy#2362 for a related PR with rational and discussion. This PR was automated using these Ruff commands (including quick fixes to ISC001): ruff format ruff check --select ISC001 --fix ruff format
Reformat Python code with a maximum line length of 88 characters to better represent the code. See modflowpy/flopy#2362 for a related PR with rational and discussion. Also change some of Ruff's configuration: - Remove target-version, since it was outdated and is automatically evaluated from pyproject.toml - Remove include so that Ruff will work globally in this repo - Remove extend-include since "*.ipynb" files are already included by default
Reformat the code with a maximum line length of 88 characters to better represent the code. See modflowpy/flopy#2362 for a related PR with rational and discussion. Also change some of Ruff's configuration: - Remove target-version, since it is automatically evaluated from pyproject.toml - Remove include so that Ruff will work globally in this repo
* ci(release): update version to 1.2.11.dev0 * ci: fix schedule for windows (#193) * fix(requests): update available assets (#194) Add macarm.zip asset * chore: reformat Python code with line length = 88 (#198) Reformat the code with a maximum line length of 88 characters to better represent the code. See modflowpy/flopy#2362 for a related PR with rational and discussion. Also change some of Ruff's configuration: - Remove target-version, since it is automatically evaluated from pyproject.toml - Remove include so that Ruff will work globally in this repo * fix: cleanup _get_optlevel verbose param in pymake_base (#199) Co-authored-by: mjreno <mjreno@IGSAAA071L01144.gs.doi.net> * refactor: clean-up strings and Path related aspects, add a few Ruff rules (#200) Refactor a few semi-related aspects: - Revise strings and whitespace using a few methods with Ruff and manual edits - Revise a few aspects of pathlib.Path -- these changes are added here to shorten some string formatting, but remain consistent throughout the code base - Fix one more instance of removed verbose parameter in _get_optlevel(), similar to #199 - Apply Ruff pyupgrade (UP) rules - Apply Ruff section-underline-matches-section-length (D409) rule - Apply Ruff-specific rules (RUF) * build(deps): bump dawidd6/action-download-artifact from 6 to 7 (#201) * update for mf6.6.0 (#203) * fix fortran submodule evaluation * update sutra and mfusg_gsi versions. * update pixi version * ci(release): set version to 1.3.0 --------- Co-authored-by: wpbonelli <wbonelli@ucar.edu> Co-authored-by: jdhughes-usgs <jdhughes@usgs.gov> Co-authored-by: Mike Taves <mwtoews@gmail.com> Co-authored-by: mjreno <renomik@gmail.com> Co-authored-by: mjreno <mjreno@IGSAAA071L01144.gs.doi.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* ci(release): update version to 1.2.11.dev0 * ci: fix schedule for windows (#193) * fix(requests): update available assets (#194) Add macarm.zip asset * chore: reformat Python code with line length = 88 (#198) Reformat the code with a maximum line length of 88 characters to better represent the code. See modflowpy/flopy#2362 for a related PR with rational and discussion. Also change some of Ruff's configuration: - Remove target-version, since it is automatically evaluated from pyproject.toml - Remove include so that Ruff will work globally in this repo * fix: cleanup _get_optlevel verbose param in pymake_base (#199) Co-authored-by: mjreno <mjreno@IGSAAA071L01144.gs.doi.net> * refactor: clean-up strings and Path related aspects, add a few Ruff rules (#200) Refactor a few semi-related aspects: - Revise strings and whitespace using a few methods with Ruff and manual edits - Revise a few aspects of pathlib.Path -- these changes are added here to shorten some string formatting, but remain consistent throughout the code base - Fix one more instance of removed verbose parameter in _get_optlevel(), similar to #199 - Apply Ruff pyupgrade (UP) rules - Apply Ruff section-underline-matches-section-length (D409) rule - Apply Ruff-specific rules (RUF) * build(deps): bump dawidd6/action-download-artifact from 6 to 7 (#201) * update for mf6.6.0 (#203) * fix fortran submodule evaluation * update sutra and mfusg_gsi versions. * update pixi version * ci: fix release code.md path (#205) * ci(release): set version to 1.3.0 --------- Co-authored-by: wpbonelli <wbonelli@ucar.edu> Co-authored-by: jdhughes-usgs <jdhughes@usgs.gov> Co-authored-by: Mike Taves <mwtoews@gmail.com> Co-authored-by: mjreno <renomik@gmail.com> Co-authored-by: mjreno <mjreno@IGSAAA071L01144.gs.doi.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This is a draft PR to investigate the utility of contributing and maintaining code with a longer line length limits.
The codebase currently has a line length limit of 79 (via #954) as suggested in PEP 8 (which is related to a 80 char limit of decades old IBM punch cards and terminals). However, longer line lengths are generally encouraged for modern Python development, which is a language that commonly has four-space indents needed to define logic structures, thus requiring more horizontal space than other programming languages.
Black has a default of 88, which is the same default for Ruff. Is this the ideal length for the flopy codebase? Not sure, but a quick scan of the suggested changes look much better.
Despite the size of this PR, it was quickly automated using these ruff commands (including quick fixes to ISC001):
There are no functional changes in this PR, thus the code "runs the same". As such,
.git-blame-ignore-revs
can be amended to ignore these changes with (e.g.) GitHub's blame view (this would be a follow-up PR).Is Anyone in favor of increasing the line length? If so, does 88 seem reasonable, or some other length?