Skip to content

Conversation

@TB-1993
Copy link
Contributor

@TB-1993 TB-1993 commented Nov 18, 2025

closes #47

Created custom argument parser and changed all argument parser used in xts, alias and allocator client to use the custom parser.

@TB-1993 TB-1993 requested a review from a team as a code owner November 18, 2025 17:01
Copilot AI review requested due to automatic review settings November 18, 2025 17:01
@github-actions
Copy link

github-actions bot commented Nov 18, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@TB-1993 TB-1993 changed the base branch from master to develop November 18, 2025 17:01
@TB-1993 TB-1993 added the enhancement New feature or request label Nov 18, 2025
@TB-1993 TB-1993 self-assigned this Nov 18, 2025
@TB-1993 TB-1993 requested a review from zghp November 18, 2025 17:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a custom argument parser (XTSArgumentParser) to replace standard argparse.ArgumentParser usage throughout the codebase. The custom parser integrates rich-argparse for enhanced help formatting and provides a custom error handler that displays help messages on argument errors.

Key changes:

  • Created new XTSArgumentParser class that extends argparse.ArgumentParser with RichHelpFormatter
  • Updated all argument parser instantiations across xts.py, xts_alias, base_plugin.py, and xts_allocator_client.py
  • Improved exception handling to use ImportError instead of bare except

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/xts_core/xts_arg_parser.py New custom argument parser class with rich formatting and custom error handling
src/xts_core/xts.py Updated to use XTSArgumentParser and improved exception handling
src/xts_core/plugins/xts_allocator_client.py Updated imports and parser instantiations to use XTSArgumentParser
src/xts_core/plugins/base_plugin.py Updated to use XTSArgumentParser and export it for plugin use
pyproject.toml Added rich-argparse dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""XTS Specific argument parser.
"""

def __init__(self,*args, **kwargs):
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Missing space after comma in parameter list. Should be def __init__(self, *args, **kwargs):

Suggested change
def __init__(self,*args, **kwargs):
def __init__(self, *args, **kwargs):

Copilot uses AI. Check for mistakes.
"""

def __init__(self,*args, **kwargs):
kwargs.pop('formatter_class','')
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The kwargs.pop('formatter_class', '') on line 34 removes the formatter_class if present, but uses an empty string as default. This should use None as the default value instead, as empty string is not a meaningful default for a class parameter: kwargs.pop('formatter_class', None)

Suggested change
kwargs.pop('formatter_class','')
kwargs.pop('formatter_class', None)

Copilot uses AI. Check for mistakes.
from rich.table import Table
try:
from base_plugin import BaseXTSPlugin, plugin_utils
from base_plugin import BaseXTSPlugin, plugin_utils, XTSArgumentParser
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Missing argparse import. The file uses argparse.ArgumentParser on line 176 (add_parser = allocator_subparsers.add_parser(...)) but no longer imports argparse after removing it. While XTSArgumentParser replaces most uses, the add_parser method call still requires argparse types or the XTSArgumentParser should be used there as well.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +17
try:
from xts_core.xts_arg_parser import XTSArgumentParser
except ImportError:
from xts_arg_parser import XTSArgumentParser
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Missing argparse import. The base_plugin.py file still needs to import argparse since it's likely used elsewhere in the file (e.g., for type hints, argument groups, or other argparse functionality). Only the ArgumentParser class is being replaced.

Copilot uses AI. Check for mistakes.
formatter_class=RichHelpFormatter)

def error(self, message):
sys.stderr.write('error: %s\n' % message)
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

[nitpick] Using old-style string formatting (%). Consider using f-strings for consistency with modern Python: sys.stderr.write(f'error: {message}\\n')

Suggested change
sys.stderr.write('error: %s\n' % message)
sys.stderr.write(f'error: {message}\n')

Copilot uses AI. Check for mistakes.
zghp
zghp previously approved these changes Nov 19, 2025
@TB-1993 TB-1993 force-pushed the feature/gh47_custom_argument_parser branch from 5909d8c to f513782 Compare November 20, 2025 15:12
@TB-1993 TB-1993 merged commit f207c53 into develop Nov 20, 2025
3 checks passed
@TB-1993 TB-1993 deleted the feature/gh47_custom_argument_parser branch November 20, 2025 15:20
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task: Custom argment parser for XTS

3 participants