[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-07 Thread Andrew Svetlov
Change by Andrew Svetlov : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: -Python 2.7, Python 3.7 ___ Python tracker ___

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-07 Thread miss-islington
miss-islington added the comment: New changeset 606ac581e2451c420117c55632f0fe13d4cec2cd by Miss Islington (bot) in branch '3.8': bpo-37150: Throw ValueError if FileType class object was passed in add_argument (GH-13805)

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-07 Thread miss-islington
Change by miss-islington : -- pull_requests: +13776 pull_request: https://github.com/python/cpython/pull/13901 ___ Python tracker ___

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-07 Thread miss-islington
miss-islington added the comment: New changeset 03d5831a2d62c68654ec223168e574cd546efbf6 by Miss Islington (bot) (zygocephalus) in branch 'master': bpo-37150: Throw ValueError if FileType class object was passed in add_argument (GH-13805)

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-07 Thread Michele Angrisano
Change by Michele Angrisano : -- nosy: +bethard ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-05 Thread Demid
Demid added the comment: What if I will add mode check in FileType.__init__? -- ___ Python tracker ___ ___ Python-bugs-list

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Josh Rosenberg
Josh Rosenberg added the comment: Ah, right. It doesn't actually validate the mode string (it just stores it for when open is called, assuming open will validate it). So yeah, it silently accepts any string, not just valid mode strings. Not a contractual guarantee or anything, just how

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Demid
Demid added the comment: If you will run `python test.py hello.txt, where test.py is: import argparse parser = argparse.ArgumentParser() parser.add_argument('echo', type=argparse.FileType) args = parser.parse_args() print(args.echo) You will receive: FileType('hello.txt') I think that can

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Michele Angrisano
Michele Angrisano added the comment: Yes, I meant that. Thanks! :) -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Josh Rosenberg
Josh Rosenberg added the comment: The docs specify what argparse.FileType() does via the default parameters: https://docs.python.org/3/library/argparse.html#argparse.FileType If you mean what does it do when you fail to call it at all (passing type=argparse.FileType), the answer is the same

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Michele Angrisano
Michele Angrisano added the comment: Reading the examples in the doc, it's clear the behavior when FileType takes an argument. What's the behavior of FileType when is called without any argument? -- nosy: +mangrisano ___ Python tracker

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread paul j3
paul j3 added the comment: I don't see an easy way around this. FileType is a class, and thus is a callable. add_argument checks that the 'type' parameter is a callable (or a string in the registry). Otherwise it gives the programmer a lot of freedom regarding this parameter. --

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +paul.j3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread SilentGhost
Change by SilentGhost : -- versions: -Python 3.5, Python 3.6 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Demid
Change by Demid : -- keywords: +patch pull_requests: +13690 stage: -> patch review pull_request: https://github.com/python/cpython/pull/13805 ___ Python tracker ___

[issue37150] Do not allow to pass FileType class object instead of instance in add_argument

2019-06-04 Thread Demid
New submission from Demid : There is a possibility that someone (like me) accidentally will omit parentheses with FileType arguments after FileType, and parser will contain wrong file until someone will try to use it. Example: parser = argparse.ArgumentParser() parser.add_argument('-x',