ConfigArgParse icon indicating copy to clipboard operation
ConfigArgParse copied to clipboard

Ability to support empty list with default parser?

Open groucho86 opened this issue 2 years ago • 1 comments

I'm hoping to be able to use the default ArgumentParser (ie, not constrained by the INI format) and have it support a config that contains empty lists like this: argument_name = []

Is this possible?

groucho86 avatar Oct 27 '23 00:10 groucho86

I tested this and it seems to already work as expected:

    def test_issue_287(self): 
        """
        Add this as a unit test to one of the test classes
        """                                                                                         
        self.initParser()
        self.add_arg("--absent", nargs="*")
        self.add_arg("--empty_list_in_conf", nargs="*")

        config_lines = [ 'empty_list_in_conf = []' ]
        ns = self.parse([], config_file_contents=("\n".join(config_lines)),
                            env_vars=dict())

        self.assertEqual(vars(ns), { 'absent': None,
                                     'empty_list_in_conf': [] })

If you still think this is an issue, please provide a code example.

tbooth avatar Apr 23 '25 10:04 tbooth