Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ logging-format-style = new
disable = C0103,R0903,E1101,E1205,W0703

[SIMILARITIES]
ignore-paths=python_gpt_po/tests
ignore-paths=python_gpt_po/tests, python_gpt_po/_version.py
Copy link
Contributor Author

@vbossica vbossica Jun 24, 2025

Choose a reason for hiding this comment

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

Without this line, after having installed the package with python -m pip install -e .:

$ pylint python_gpt_po/
************* Module python_gpt_po._version
python_gpt_po/_version.py:1:0: C0114: Missing module docstring (missing-module-docstring)

------------------------------------------------------------------
Your code has been rated at 9.98/10 (previous run: 9.98/10, +0.00)

3 changes: 2 additions & 1 deletion python_gpt_po/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import sys
import traceback
from argparse import Namespace
from typing import Dict, List, Optional

from .models.config import TranslationConfig
Expand All @@ -30,7 +31,7 @@ def setup_logging():
)


def initialize_provider(args) -> tuple[ProviderClients, ModelProvider, str]:
def initialize_provider(args: Namespace) -> tuple[ProviderClients, ModelProvider, str]:
"""
Initialize the provider client and determine the appropriate model.

Expand Down
20 changes: 10 additions & 10 deletions python_gpt_po/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
This module provides the argument parsing and command-line handling functionality,
including argument definitions, help text generation, and command processing.
"""
import argparse
import logging
import os
import sys
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
from typing import Dict, List, Optional

from ..models.enums import ModelProvider
from .helpers import get_version


class CustomArgumentParser(argparse.ArgumentParser):
class CustomArgumentParser(ArgumentParser):
"""
Custom ArgumentParser that handles errors in a more user-friendly way.
"""
def error(self, message):
def error(self, message: str):
"""
Display a cleaner error message with usage information.

Expand All @@ -29,12 +29,12 @@ def error(self, message):
sys.exit(2)


def parse_args():
def parse_args() -> Namespace:
"""
Parse command-line arguments with a more user-friendly interface.

Returns:
argparse.Namespace: Parsed arguments
Namespace: Parsed arguments
"""
# First pass - check if list-models is in args
# This allows us to make folder and lang not required when listing models
Expand All @@ -59,7 +59,7 @@ def parse_args():
# Process multiple translations in bulk with a specific model
gpt-po-translator --folder ./locales --lang ja,ko --bulk --model gpt-4
""",
formatter_class=lambda prog: argparse.RawDescriptionHelpFormatter(prog, max_help_position=35, width=100)
formatter_class=lambda prog: RawDescriptionHelpFormatter(prog, max_help_position=35, width=100)
)

# Create argument groups for better organization
Expand Down Expand Up @@ -222,12 +222,12 @@ def create_language_mapping(lang_codes: List[str], detail_langs_arg: Optional[st
return dict(zip(lang_codes, detail_langs))


def get_provider_from_args(args) -> Optional[ModelProvider]:
def get_provider_from_args(args: Namespace) -> Optional[ModelProvider]:
"""
Get the provider from command line arguments.

Args:
args (argparse.Namespace): Parsed command line arguments
args (Namespace): Parsed command line arguments

Returns:
Optional[ModelProvider]: The selected provider or None if not specified
Expand All @@ -237,12 +237,12 @@ def get_provider_from_args(args) -> Optional[ModelProvider]:
return None


def get_api_keys_from_args(args) -> Dict[str, str]:
def get_api_keys_from_args(args: Namespace) -> Dict[str, str]:
"""
Extract API keys from command line arguments and environment variables.

Args:
args (argparse.Namespace): Parsed command line arguments
args (Namespace): Parsed command line arguments

Returns:
Dict[str, str]: Dictionary of provider names to API keys
Expand Down