Skip to content

Commit fe88397

Browse files
committed
FIX: account for changes in py310
In python/cpython#28420 the order of setting the default values on the Namespace object and processing the Actions was reversed. This means that in the `__call__` method of `_FlagAction` the `_flags` attribute has not yet been put on the namespace. This change makes `_FlagAction.__call__` forgiving if the `_flags` attribute does not exist (by creating it!).
1 parent 2bb2597 commit fe88397

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

traitlets/config/loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ def __init__(self, *args, **kwargs):
928928

929929
def __call__(self, parser, namespace, values, option_string=None):
930930
if self.nargs == 0 or values is Undefined:
931+
if not hasattr(namespace, '_flags'):
932+
namespace._flags = []
931933
namespace._flags.append(self.flag)
932934
else:
933935
setattr(namespace, self.alias, values)

0 commit comments

Comments
 (0)