Don't use mutable defaults for SCMClient methods.
Review Request #14471 — Created June 24, 2025 and updated
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.
Summary | ID |
---|---|
f4d05933ad0520da8f5ce34d9a9b67a699905a3d |
Description | From | Last Updated |
---|---|---|
'typing.List' imported but unused Column: 1 Error code: F401 |
![]() |
|
'typing.List' imported but unused Column: 1 Error code: F401 |
![]() |
|
Why do we need to add | None here? |
![]() |
|
If calling the SCMClient's diff() directly, I think it's reasonable to be able to leave off these argument. I think … |
|
|
Should this assert, or should we fall back to a value? This might be called manually be a caller, not … |
|
|
Isn't the is not None check redundant since we check if its a dict right after? |
![]() |
|
'typing.Type' imported but unused Column: 1 Error code: F401 |
![]() |
- Commits:
-
Summary ID 25d4f739ac3024bbea14f0a15d970c21c3144268 c90a2de378ec581efb1f70e7e470abb1844ef5d5
Checks run (2 succeeded)
-
This is overall good, but two things stand out:
-
diff()
is being treated as an internal function, with optional arguments now made mandatory. I don't think we should be doing this. This method can be called by utility scripts, and as those arguments aren't required for building a standard diff, I believe they should remain optional. (This would also mean undoing the unit test changes that pass in empty values so that we can make sure they remain optional). -
This makes changes to Plastic that are going to conflict with pending work on my end. Can we ignore this module for now?
-
-
If calling the SCMClient's
diff()
directly, I think it's reasonable to be able to leave off these argument. I think they should stay optional. -
Should this assert, or should we fall back to a value? This might be called manually be a caller, not just internally.
- Commits:
-
Summary ID c90a2de378ec581efb1f70e7e470abb1844ef5d5 d18d727f97c1c748d7233ed93d06cbf78e89101c