fix: add type annotations to cli.py
Some checks failed
CI / test (push) Failing after 12s
CI / build (push) Has been skipped

This commit is contained in:
2026-02-02 07:00:18 +00:00
parent 9d42a01264
commit 72a65bcda8

View File

@@ -1,10 +1,11 @@
"""Main CLI module for Regex Humanizer."""
import json as json_module
from typing import List
import click
from .parser import parse_regex, ParseError
from .parser import ASTNode, ParseError
from .converter import convert_to_english, convert_to_english_verbose
from .examples import generate_examples
from .flavors import (
@@ -72,7 +73,7 @@ def explain(pattern: str, flavor: str, verbose: bool, output_format: str):
click.echo(f"Flavor: {result['flavor']}")
click.echo(f"\nDescription:\n{result['description']}")
if result.get('structure'):
click.echo(f"\nStructure:")
click.echo("\nStructure:")
for item in result['structure']:
click.echo(f" - {item}")
else:
@@ -87,7 +88,7 @@ def explain(pattern: str, flavor: str, verbose: bool, output_format: str):
warnings = get_compatibility_warnings(pattern, flavor)
if warnings:
click.echo(f"\nCompatibility warnings:")
click.echo("\nCompatibility warnings:")
for w in warnings:
click.echo(f" [{w.severity.upper()}] {w.feature}: {w.message}")
@@ -150,7 +151,7 @@ def generate(pattern: str, flavor: str, count: int, output_format: str):
else:
click.echo(f"\nPattern: {pattern}")
click.echo(f"Flavor: {flavor}")
click.echo(f"\nMatching examples:")
click.echo("\nMatching examples:")
for i, example in enumerate(examples, 1):
click.echo(f" {i}. {example}")
@@ -198,7 +199,7 @@ def from_english(description: str, flavor: str, output_format: str):
click.echo(f"Flavor: {result['flavor']}")
if result.get('warnings'):
click.echo(f"\nWarnings:")
click.echo("\nWarnings:")
for w in result['warnings']:
click.echo(f" - {w}")
@@ -226,7 +227,7 @@ def build(flavor: str):
click.echo(f"Flavor: {flavor}")
click.echo("Enter 'quit' to exit, 'back' to go back, 'done' when finished.\n")
pattern_parts = []
pattern_parts: List[ASTNode] = []
while True:
current_pattern = "".join(p.to_regex() if hasattr(p, 'to_regex') else str(p) for p in pattern_parts)