Skip to content

Commit bce1240

Browse files
author
SunDoge
authored
Merge pull request #14 from SunDoge/new-api
update api
2 parents 6bd2b80 + 6283246 commit bce1240

File tree

10 files changed

+18
-14
lines changed

10 files changed

+18
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.6.2]
11+
12+
- Add `ta.TypedArgs` for better intellisense.
13+
1014
## [0.6.1]
1115

1216
- Add `@overload` for API.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from typing import List, Callable
2323
@ta.argument_parser(
2424
description='Process some integers.'
2525
)
26-
class Args:
26+
class Args(ta.TypedArgs):
2727
integers: List[int] = ta.add_argument(
2828
metavar='N', type=int, nargs='+',
2929
help='an integer for the accumulator'
@@ -110,7 +110,7 @@ parser = argparse.ArgumentParser(prog='ProgramName')
110110
import typed_args as ta
111111

112112
@ta.argument_parser(prog='ProgramName')
113-
class Args:
113+
class Args(ta.TypedArgs):
114114
pass
115115
```
116116

@@ -133,7 +133,7 @@ parser.add_argument('-v', '--verbose',
133133
import typed_args as ta
134134

135135
@ta.argument_parser()
136-
class Args:
136+
class Args(ta.TypedArgs):
137137
filename: str = ta.add_argument() # positional argument, use the attribute name automatically
138138
count: str = ta.add_argument('-c', '--count') # option that takes a value, also can be annotated as Optional[str]
139139
verbose: bool = ta.add_argument('-v', '--verbose',

_test_v0_6.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SubCommands(ta.SubcommandEnum):
3535

3636

3737
@ta.argument_parser(prog='dddd')
38-
class Args:
38+
class Args(ta.TypedArgs):
3939
x1: str = ta.add_argument()
4040
group1: Group1 = ta.add_argument_group()
4141
group2: Group2 = ta.add_argument_group()

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ from typing import List, Callable
1616
@ta.argument_parser(
1717
description='Process some integers.'
1818
)
19-
class Args:
19+
class Args(ta.TypedArgs):
2020
integers: List[int] = ta.add_argument(
2121
metavar='N', type=int, nargs='+',
2222
help='an integer for the accumulator'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "typed-args"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
description = "Parse command line arguments by defining dataclasses"
55
authors = ["SunDoge <384813529@qq.com>"]
66
readme = "README.md"

tests/test_add_argument.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def test_name_or_flags():
88
@ta.argument_parser()
9-
class Args:
9+
class Args(ta.TypedArgs):
1010
foo: str = ta.add_argument('-f', '--foo')
1111
bar: str = ta.add_argument()
1212

@@ -24,7 +24,7 @@ class Args:
2424

2525
def test_store_action():
2626
@ta.argument_parser()
27-
class Args:
27+
class Args(ta.TypedArgs):
2828
foo: str = ta.add_argument('--foo')
2929

3030
args = Args.parse_args('--foo 1'.split())
@@ -33,7 +33,7 @@ class Args:
3333

3434
def test_store_const_action():
3535
@ta.argument_parser()
36-
class Args:
36+
class Args(ta.TypedArgs):
3737
foo: int = ta.add_argument('--foo', action='store_const', const=42)
3838

3939
args = Args.parse_args(['--foo'])

tests/test_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_list():
1010
"""
1111

1212
@ta.argument_parser()
13-
class Args:
13+
class Args(ta.TypedArgs):
1414
foo: List[str] = ta.add_argument('--foo', nargs=2, type=str)
1515
bar: List[str] = ta.add_argument(nargs=1, type=str)
1616

@@ -22,7 +22,7 @@ class Args:
2222

2323
def test_default_list():
2424
@ta.argument_parser()
25-
class Args:
25+
class Args(ta.TypedArgs):
2626
foo: int = ta.add_argument('--foo', type=int, default=42)
2727
bar: List[int] = ta.add_argument(nargs='*', default=[1, 2, 3])
2828
config: List[str] = ta.add_argument(

tests/test_pickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@ta.argument_parser()
9-
class Args:
9+
class Args(ta.TypedArgs):
1010
foo: Optional[str] = ta.add_argument('--foo')
1111
bar: List[int] = ta.add_argument(nargs='*', default=[1, 2, 3])
1212

tests/test_readme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
TypedArgs
2424
"""
2525
@ta.argument_parser()
26-
class Args:
26+
class Args(ta.TypedArgs):
2727
data: str = ta.add_argument(
2828
metavar='DIR', type=str, help='path to dataset'
2929
)

typed_args/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ._utils import SubcommandEnum, DefaultHelpFormatter
1414
from argparse import SUPPRESS, OPTIONAL, ZERO_OR_MORE, ONE_OR_MORE, REMAINDER
1515

16-
__version__ = "0.6.1"
16+
__version__ = "0.6.2"
1717

1818
__all__ = [
1919
'dataclass',

0 commit comments

Comments
 (0)