Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use subparser dest instead of default arg #49

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/tyora/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,13 @@ def parse_args(args: Optional[list[str]] = None) -> argparse.Namespace:
help="Don't store cookies or cache (they're used for faster access on the future runs)",
action="store_true",
)
subparsers = parser.add_subparsers(required=True)
subparsers = parser.add_subparsers(required=True, dest="cmd")

# login subparser
parser_login = subparsers.add_parser("login", help="Login to mooc.fi CSES")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local variable parser_login is assigned but never used.

Consider removing or utilizing the parser_login variable. If it's intended for future use, perhaps add a comment explaining its purpose.

parser_login.set_defaults(cmd="login")

# list exercises subparser
parser_list = subparsers.add_parser("list", help="List exercises")
parser_list.set_defaults(cmd="list")
parser_list.add_argument(
"--filter",
help="List only complete or incomplete tasks (default: all)",
Expand All @@ -150,12 +148,10 @@ def parse_args(args: Optional[list[str]] = None) -> argparse.Namespace:

# show exercise subparser
parser_show = subparsers.add_parser("show", help="Show details of an exercise")
parser_show.set_defaults(cmd="show")
parser_show.add_argument("task_id", help="Numerical task identifier")

# submit exercise solution subparser
parser_submit = subparsers.add_parser("submit", help="Submit an exercise solution")
parser_submit.set_defaults(cmd="submit")
parser_submit.add_argument(
"--filename",
help="Filename of the solution to submit (if not given will be guessed from task description)",
Expand Down
Loading