Skip to content

Commit

Permalink
update examples, test, version etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatkj committed Jul 8, 2024
1 parent ae0cebf commit c0f6359
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 37 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ import os
import sys
from typing import Dict, List, Optional, Tuple, Union

from typed_argparser import ArgumentClass
from typed_argparser.fields import argfield
from typed_argparser import ArgumentClass, argfield


class Example1(ArgumentClass):
Expand Down
3 changes: 1 addition & 2 deletions examples/example_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
cwd = os.path.dirname(os.path.realpath(__file__))
sys.path.append(f"{cwd}/../")

from typed_argparser import ArgumentClass # noqa: E402
from typed_argparser.fields import argfield # noqa: E402
from typed_argparser import ArgumentClass, argfield # noqa: E402


class Example1(ArgumentClass):
Expand Down
15 changes: 7 additions & 8 deletions examples/example_2.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from io import TextIOWrapper
import os
import sys
from typing import Dict, List, Optional, Union
from typing_extensions import Annotated
from io import TextIOWrapper
from pathlib import Path
from typing import Dict, List, Optional, Union

from typing_extensions import Annotated

cwd = os.path.dirname(os.path.realpath(__file__))
sys.path.append(f"{cwd}/../")

from typed_argparser import ArgumentClass, argfield # noqa: E402
from typed_argparser.types import Args # noqa: E402
from typed_argparser import ArgumentClass # noqa: E402
from typed_argparser.fields import argfield # noqa: E402


class Example2(ArgumentClass):
Expand All @@ -32,18 +31,18 @@ class Example2(ArgumentClass):


@cli.execute("opt1", "opt2")
def execute_1(opt1: str, opt2: List[str]):
def execute_1(opt1: str, opt2: List[str]) -> None:
print("This function is executed when both function arguments are provided.")
print(f"opt1: {opt1}, opt2: {opt2}")


@cli.execute("opt3")
def execute_2(opt3: TextIOWrapper):
def execute_2(opt3: TextIOWrapper) -> None:
opt3.write("This is written to the output file.")


@cli.execute("opt4")
def execute_3(opt4: Dict[str, int]):
def execute_3(opt4: Dict[str, int]) -> None:
print("This will not be executed as opt4 is not provided.")


Expand Down
7 changes: 3 additions & 4 deletions examples/git_cli/add_group.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import List, Optional
from pathlib import Path
from typing import List, Optional

from typing_extensions import Annotated, Doc

from typed_argparser import SUPPRESS, ArgumentClass
from typed_argparser.fields import argfield
from typed_argparser import ArgumentClass, argfield
from typed_argparser.constants import SUPPRESS
from typed_argparser.groups import ArgumentGroup


from .common import CommonParameters


Expand Down
2 changes: 1 addition & 1 deletion examples/git_cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from typing_extensions import Annotated, Doc, List

from typed_argparser import argfield
from typed_argparser.constants import SUPPRESS
from typed_argparser.fields import argfield


class CommonParameters:
Expand Down
18 changes: 5 additions & 13 deletions examples/git_cli/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
cwd = os.path.dirname(os.path.realpath(__file__))
sys.path.append(f"{cwd}/../../")

from typed_argparser import SUPPRESS, ArgumentClass # noqa: E402
from typed_argparser import ArgumentClass, argfield # noqa: E402
from typed_argparser.constants import SUPPRESS # noqa: E402
from typed_argparser.config import ArgumentConfig # noqa: E402
from examples.git_cli.add_group import AddGroup # noqa: E402
from examples.git_cli.init_group import InitGroup # noqa: E402
from examples.git_cli.remote_group import RemoteCommand # noqa: E402
from typed_argparser.fields import argfield # noqa: E402


class Git(ArgumentClass, AddGroup, InitGroup):
Expand Down Expand Up @@ -58,25 +58,17 @@ class Git(ArgumentClass, AddGroup, InitGroup):


@git_cli.execute
def show_help():
def show_help() -> None:
git_cli.print_help()


@git_cli.remote.execute
def show_remote():
def show_remote() -> None:
git_cli.remote.print_help()


@git_cli.remote.add.execute
def add_remote(name, url, *, branch: Optional[str] = None):
def add_remote(name: str, url: str, *, branch: Optional[str] = None) -> None:
print(f"Adding remote {name} at {url}")
print("Info:")
print(f"\tBranch {branch}")
# print(f"\tMaster {master}")
# print(f"\tTags {tags}")
# print(f"\tMirror {mirror}")


# @git_cli.execute()
# def show_default():
# print("this is default")
3 changes: 1 addition & 2 deletions examples/git_cli/init_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from typing_extensions import Annotated, Doc

from typed_argparser import ArgumentClass
from typed_argparser.fields import argfield
from typed_argparser import ArgumentClass, argfield
from typed_argparser.groups import ArgumentGroup

from .common import Directory
Expand Down
2 changes: 1 addition & 1 deletion examples/git_cli/remote_group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Literal, Optional

from typed_argparser import argfield
from typed_argparser.constants import SUPPRESS
from typed_argparser.fields import argfield
from typed_argparser.groups import ArgumentGroup
from typed_argparser.parser import ArgumentClass
from typed_argparser.validators import UrlValidator
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

from typing_extensions import Annotated, Doc

from typed_argparser import ArgumentClass, ArgumentConfig
from typed_argparser import ArgumentClass, ArgumentConfig, argfield
from typed_argparser.constants import SUPPRESS
from typed_argparser.exceptions import ArgumentError, ValidatorInitError
from typed_argparser.fields import argfield

from typed_argparser.groups import ArgumentGroup
from typed_argparser.types import Args, UrlType
from typed_argparser.validators import (
Expand Down
6 changes: 4 additions & 2 deletions typed_argparser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from .config import ArgumentConfig
from .constants import SUPPRESS
from .parser import ArgumentClass
from .validators import ArgumentValidator
from .fields import argfield

__all__ = [
"ArgumentClass",
"ArgumentConfig",
"SUPPRESS",
"ArgumentValidator",
"argfield",
]

__version__ = "1.0.0"

0 comments on commit c0f6359

Please sign in to comment.