Skip to content

Fix 17 mutable default arguments across 8 files#196

Open
stef41 wants to merge 1 commit intousnistgov:mainfrom
stef41:fix-mutable-default-arguments
Open

Fix 17 mutable default arguments across 8 files#196
stef41 wants to merge 1 commit intousnistgov:mainfrom
stef41:fix-mutable-default-arguments

Conversation

@stef41
Copy link
Copy Markdown

@stef41 stef41 commented Apr 11, 2026

Summary

17 function signatures across 8 files use mutable default arguments (=[], ={}), which is a well-known Python anti-pattern. Mutable defaults are evaluated once at function definition time and shared across all calls, so data from one invocation can silently persist into the next.

Changes

Replaced mutable defaults with None and added if param is None: param = ... initialization guards.

Affected modules

  • alignn/models/ (alignn_atomwise, alignn_ff, utils)
  • alignn/ (config, graphs)
  • alignn/ff/

All modified files pass python -m py_compile.

Replace mutable default arguments (=[], ={}) with None and
initialize inside the function body. Mutable defaults are shared
between calls and can cause subtle bugs.

Affected files:
- alignn/models/ (alignn_atomwise, alignn_ff, utils)
- alignn/ (config, graphs, ff/ff_optb88vdw)
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