This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zerkms
Recipients docs@python, zerkms
Date 2019-11-19.02:23:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574130223.67.0.390215742489.issue38843@roundup.psfhosted.org>
In-reply-to
Content
At this moment it's impossible to explain the behaviour of this script using documentation.

Given it was explicitly coded to behave like that - it should be somehow noted in the documentation, that as long as a `CliArgs.foo` field has a default value set already - it won't be overwritten with a default argparse argument value.


```
import argparse

class CliArgs(object):
    foo: str = 'not touched'


parser = argparse.ArgumentParser()
parser.add_argument('--foo', default='bar')

args = CliArgs()
parser.parse_args(namespace=args)
print(args.foo) # 'not touched'

print(parser.parse_args()) # 'bar'
```
History
Date User Action Args
2019-11-19 02:23:43zerkmssetrecipients: + zerkms, docs@python
2019-11-19 02:23:43zerkmssetmessageid: <1574130223.67.0.390215742489.issue38843@roundup.psfhosted.org>
2019-11-19 02:23:43zerkmslinkissue38843 messages
2019-11-19 02:23:43zerkmscreate