Closed
Description
The argparse.Namespace
class stub doesn't reflect its actual complexity -- it has dynamically created attributes based on the parser specification. For example:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--database', type=str, default='data.db')
def foo(args: argparse.Namespace):
print(args.database)
def main():
args = parser.parse_args()
assert args.__class__ is argparse.Namespace
foo(args)
This gives these errors:
t.py: note: In function "foo":
t.py:5: error: "Namespace" has no attribute "database"
Now, ideally there would be some kind of plugin that understands the parser specification. But I'd be happy if it just didn't complain about using unknown attributes of Namespace
objects, while still verifying that the caller indeed passes something of that type (so I don't want to just use Any
).
Metadata
Metadata
Assignees
Labels
No labels