Don't use mutable defaults for SCMClient methods.

Review Request #14471 — Created June 24, 2025 and submitted — Latest diff uploaded

Information

RBTools
master

Reviewers

This change updates the parse_revision_spec, diff, and
create_commit methods for SCMClients to avoid using mutable lists as
defaults for arguments. These are now set to use
(Sequence[str] | None) = None, and initialize the values in the body
of the method instead.

Because all "real" call sites pass these in (as empty lists), I've
added deprecation warnings that we will be removing the default value
(and the | None) in rbtools 8.

Ran unit tests.

Diff Revision 4 (Latest)

orig
1
2
3
4

Commits

First Last Summary ID Author
Don't use mutable defaults for SCMClient methods.
This change updates the `parse_revision_spec`, `diff`, and `create_commit` methods for SCMClients to avoid using mutable lists as defaults for arguments. These are now set to use `(Sequence[str] | None) = None`, and initialize the values in the body of the method instead. Because all "real" call sites pass these in (as empty lists), I've added deprecation warnings that we will be removing the default value (and the `| None`) in rbtools 8. Testing Done: Ran unit tests.
f4d05933ad0520da8f5ce34d9a9b67a699905a3d David Trowbridge
rbtools/clients/bazaar.py
rbtools/clients/clearcase.py
rbtools/clients/cvs.py
rbtools/clients/git.py
rbtools/clients/jujutsu.py
rbtools/clients/mercurial.py
rbtools/clients/perforce.py
rbtools/clients/plastic.py
rbtools/clients/sos.py
rbtools/clients/svn.py
rbtools/clients/tfs.py
rbtools/clients/base/scmclient.py
rbtools/clients/tests/__init__.py
rbtools/clients/tests/test_bzr.py
rbtools/clients/tests/test_git.py
rbtools/clients/tests/test_jujutsu.py
rbtools/clients/tests/test_mercurial.py
rbtools/clients/tests/test_p4.py
rbtools/clients/tests/test_sos.py
rbtools/clients/tests/test_svn.py
rbtools/commands/diff.py
rbtools/utils/diffs.py
Loading...