An alternate suggestion to #93
Instead of parsing source code (which many will find surprising behavior), a cleaner and more intuitive approach would be to use a custom type that's capable of taking the extra meta information. This pattern is well established by both the standard library and other popular third party libraries like dataclass, sqlalchemy, pydantic etc. For example, when you declare a dataclass,
from dataclass import dataclass, field
@dataclass
class User:
name: str = "John Doe" # This is the normal way of setting the default
password: str = field("p@ssw0rd", repr=False) # This allows setting the default AND other properties
In case of tap, the declaration would look something like
from tap import Tap, Arg
class SimpleArgumentParser(Tap):
language: str = 'Python'
package: str = Arg('Tap', help="Package name") # Now I can leave comments that don't affect behavior!! e.g.: pylint: disable=...
An alternate suggestion to #93
Instead of parsing source code (which many will find surprising behavior), a cleaner and more intuitive approach would be to use a custom type that's capable of taking the extra meta information. This pattern is well established by both the standard library and other popular third party libraries like
dataclass,sqlalchemy,pydanticetc. For example, when you declare a dataclass,In case of tap, the declaration would look something like