Skip to content

chore(lint): fix the ruff findings in Dynamics.py and RobotProto.py, except module names - #880

Merged
petercorke merged 1 commit into
mainfrom
fix/ruff-dynamics
Oct 21, 2026
Merged

petercorke merged 1 commit into
mainfrom
fix/ruff-dynamics

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Fixes the ruff findings in robot/Dynamics.py and robot/RobotProto.py, except N999 (CamelCase module names, which is Toolbox-wide) and one TRY004 that is in pay() (see below).

  • B006, mutable default arguments: fdyn(Q_args={}, solver_args={}) now defaults to None and makes the dict inside. A default dict is one object shared by every call.
  • B008, a call in a default argument: payload(m, p=np.zeros(3)) is now p=None, which means the origin of the end-effector frame, as the docstring says. Behaviour is the same.
  • UP035, UP034, SIM102, I001: Callable from collections.abc; extra parentheses in np.zeros((self.n)); a nested if that is one condition; the import order.
  • A new tests/test_dynamics_defaults.py checks that the defaults are None, that payload(m) equals payload(m, [0, 0, 0]), and that fdyn runs without the optional arguments.

Not changed: TRY004 at the raise ValueError("W is invalid") in pay(). pay() is being removed in the payload capacity work, so changing its exception type would be wasted.

Changes numerical results or public behaviour: no. The signatures say dict | None and ArrayLike | None where they said dict and Any; a call that worked still works.

Ran: the dynamics-related tests (222 passed, 1 skipped) and mypy (clean, 165 files); ruff check on the two files shows only N999 and TRY004.

Written with Claude Code.

🤖 Generated with Claude Code

…except module names

fdyn took Q_args and solver_args with {} as the default, and payload took np.zeros(3):
a mutable default is one object shared by every call, and a call as a default is made
once.  They are None now, and the object is made inside.  Also: Callable from
collections.abc, an if that was nested for no reason, extra parentheses, and the import
order.  N999 (CamelCase module names) is not changed, it is Toolbox-wide.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke enabled auto-merge (squash) October 21, 2026 23:31
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 high

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
Security 3 high

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 1c098bd into main Oct 21, 2026
22 of 23 checks passed
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (4512e47) to head (7cd949b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/roboticstoolbox/robot/Dynamics.py 0.00% 10 Missing ⚠️
src/roboticstoolbox/robot/RobotProto.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #880   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        146     146           
  Lines      17100   17103    +3     
=====================================
- Misses     17100   17103    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@petercorke
petercorke deleted the fix/ruff-dynamics branch October 22, 2026 04:40
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.

1 participant