How to use argparse.FileType?
s3rgeym opened this issue · 1 comments
s3rgeym commented
class Args(Tap):
depth: int = 2 # max crawling depth
visits_per_domain: int = 50 # limit visits per domain
def configure(self) -> None:
self.add_argument(
"-i", "--input", help="site urls", default="-", type=argparse.FileType()
)
❯ poetry run sqli-scanner
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/semen/workspace/sqli-scanner/sqli_scanner/cli.py", line 22, in cli
asyncio.run(run(Args().parse_args()))
^^^^^^^^^^^^^^^^^^^
File "/home/semen/.cache/pypoetry/virtualenvs/sqli-scanner--aOpk7rM-py3.11/lib/python3.11/site-packages/tap/tap.py", line 460, in parse_args
setattr(self, variable, deepcopy(value))
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/copy.py", line 161, in deepcopy
rv = reductor(4)
^^^^^^^^^^^
TypeError: cannot pickle '_io.TextIOWrapper' object
swansonk14 commented
Hi @s3rgeym,
Thank you for bringing up this issue! It looks like this is a problem with deepcopy
, which we use to enforce immutability of default values. We have moved deepcopy
earlier in the pipeline, which avoids this error. (See these commits: 33e7c53 and 04357df). This fix will be included in the next release.
Best,
Kyle and Jesse