bpo-37150: Throw ValueError if FileType class object was passed in add_argument (GH-13805)

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:
```python
parser = argparse.ArgumentParser()
parser.add_argument('-x', type=argparse.FileType)
```


https://bugs.python.org/issue37150
This commit is contained in:
zygocephalus 2019-06-07 23:08:36 +03:00 committed by Miss Islington (bot)
parent 1f9531764c
commit 03d5831a2d
3 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1 @@
`argparse._ActionsContainer.add_argument` now throws error, if someone accidentally pass FileType class object instead of instance of FileType as `type` argument