Skip to content

Add ruff workflow and enforce stricter linting rules#433

Merged
A-CGray merged 16 commits into
smdogroup:masterfrom
mdolab:ruff
Jun 29, 2026
Merged

Add ruff workflow and enforce stricter linting rules#433
A-CGray merged 16 commits into
smdogroup:masterfrom
mdolab:ruff

Conversation

@eirikurj

@eirikurj eirikurj commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Description

This PR replaces black with a ruff formatting and linting CI workflow.

The defaults for formatting should be the same as the ones found in black. For example, the default line length is 88 characters.

The ruff linting rules are added to the pyproject.toml file along with some common exceptions. The linting exceptions are minimal but necessary in my opinion, but there are some there that we might want to work on getting removed in the future.

Note, currently there are tests and examples that will fail the linting and need attention. In some cases its not clear what the author's intent was, and in others more extensive refactoring could be done (e.g. setup_tacs_vecs is largly the same in many tests and could be shared across many).

Closes #429

@eirikurj
eirikurj marked this pull request as draft April 7, 2026 11:21
@eirikurj
eirikurj requested review from A-CGray and timryanb and removed request for A-CGray April 7, 2026 15:45
@A-CGray

A-CGray commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@eirikurj I fixed the outstanding linting issues but there are a lot of changes so I opened a PR (mdolab#6) to this branch so you can review

eirikurj and others added 2 commits June 22, 2026 11:55
* fix F401 re-export __all__ desyncs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* replace star imports with explicit imports (F403/F405)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix E402 import placement

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix F821 undefined names

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix F841 unused variables (mechanical cleanup + getLocalCoords refactor)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* support kcorr in IsoShellConstitutive and use PSHELL TST factor

Add a shear-correction-factor (kcorr) constructor argument to
IsoShellConstitutive (default 5/6, mirroring CompositeShellConstitutive)
and pass the PSHELL TST field through to it in pyTACS, instead of reading
TST into a dead local. Previously the BDF shear-correction factor was
silently ignored for isotropic shells.

Requires a full rebuild (C++ + Cython interface); not buildable/testable
in the current environment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* remove dead unused locals (F841)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix StaticProblem.setOption to skip solver recreation on tolerance change

The L2Convergence-update branch set a dead local `createVariables = False`
that was never read; the flag actually consulted before recreating the
linear solver is `recreateSolver`. Setting `recreateSolver = False` here
skips the redundant `self._createSolver()` call when only the convergence
tolerance changed (the tolerance is already updated in place via
setTolerances), matching the intent of the dead flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* pass struct_options to static problem in thermal IC test

The struct_options dict ({"L2Convergence": 1e-16}, commented as the finer
tolerance needed to pass the complex-step sensitivity test) was built but
never passed to any problem. L2Convergence is a problem-level option, so
forward it to createStaticProblem (mirroring the transient problem's
options= usage in the same test).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* avoid mutable default arguments (B006)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix unused loop control variables (B007)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* bind loop variables to avoid late-binding closures (B023)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* add stacklevel to warnings.warn calls (B028)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chain exceptions with 'from err' (B904)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix E712/E731/W293 lint issues

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix F401 re-export __all__ desyncs in merged modules

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* remove unused imports from merged code (F401)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* remove duplicate PT import (E402/F811)

Consolidate the test_rectangle_beam_tractions import to the top import
block (including ksweight) and drop the late duplicate that the upstream
merge reintroduced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix docstring section/quote formatting (D409/D209)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* another import fix

* Regenerate reference matvec results due to slight `kcorr` change

* renaming for clarity

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Eirikur Jonsson <eirikurj@umich.edu>
@eirikurj
eirikurj marked this pull request as ready for review June 27, 2026 11:49
@A-CGray
A-CGray merged commit f017017 into smdogroup:master Jun 29, 2026
6 checks passed
@A-CGray
A-CGray deleted the ruff branch June 29, 2026 14:55
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.

Use ruff for python linting and formatting

2 participants