-
Notifications
You must be signed in to change notification settings - Fork 422
config: T0000: fix mutable default argument in config API methods #5075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: current
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -480,7 +480,7 @@ def return_value(self, path, default=None): | |
| else: | ||
| return(value) | ||
|
|
||
| def return_values(self, path, default=[]): | ||
| def return_values(self, path, default=None): | ||
| """ | ||
| Retrieve all values of a multi-value leaf node in the running or proposed config | ||
|
|
||
|
|
@@ -495,6 +495,8 @@ def return_values(self, path, default=[]): | |
| This function cannot be used outside a configuration session. | ||
| In operational mode scripts, use ``return_effective_values``. | ||
| """ | ||
| if default is None: | ||
| default = [] | ||
| if self._session_config: | ||
| try: | ||
| values = self._session_config.return_values(self._make_path(path)) | ||
|
|
@@ -508,7 +510,7 @@ def return_values(self, path, default=[]): | |
| else: | ||
| return(values) | ||
|
|
||
| def list_nodes(self, path, default=[]): | ||
| def list_nodes(self, path, default=None): | ||
| """ | ||
| Retrieve names of all children of a tag node in the running or proposed config | ||
|
|
||
|
|
@@ -519,6 +521,8 @@ def list_nodes(self, path, default=[]): | |
| string list: child node names | ||
|
|
||
| """ | ||
|
Comment on lines
513
to
523
|
||
| if default is None: | ||
| default = [] | ||
| if self._session_config: | ||
| try: | ||
| nodes = self._session_config.list_nodes(self._make_path(path)) | ||
|
|
@@ -596,7 +600,7 @@ def return_effective_value(self, path, default=None): | |
| else: | ||
| return(value) | ||
|
|
||
| def return_effective_values(self, path, default=[]): | ||
| def return_effective_values(self, path, default=None): | ||
| """ | ||
| Retrieve all values of a multi-value node in a running (effective) config | ||
|
|
||
|
|
@@ -606,6 +610,8 @@ def return_effective_values(self, path, default=[]): | |
| Returns: | ||
| str list: A list of values | ||
| """ | ||
|
Comment on lines
603
to
612
|
||
| if default is None: | ||
| default = [] | ||
| if self._running_config: | ||
| try: | ||
| values = self._running_config.return_values(self._make_path(path)) | ||
|
|
@@ -619,7 +625,7 @@ def return_effective_values(self, path, default=[]): | |
| else: | ||
| return(values) | ||
|
|
||
| def list_effective_nodes(self, path, default=[]): | ||
| def list_effective_nodes(self, path, default=None): | ||
| """ | ||
| Retrieve names of all children of a tag node in the running config | ||
|
|
||
|
|
@@ -629,6 +635,8 @@ def list_effective_nodes(self, path, default=[]): | |
| Returns: | ||
| str list: child node names | ||
| """ | ||
|
Comment on lines
628
to
637
|
||
| if default is None: | ||
| default = [] | ||
| if self._running_config: | ||
| try: | ||
| nodes = self._running_config.list_nodes(self._make_path(path)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says mutable defaults were fixed for the Config API methods listed, but this file still contains mutable default arguments (e.g.,
get_config_dict(self, path=...)andget_config_defaults(self, path=...)usepath=[]). Either include those in this change set or adjust the PR description/scope so it’s not misleading.