fix: add type annotations to cli.py
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
"""Main CLI module for Regex Humanizer."""
|
"""Main CLI module for Regex Humanizer."""
|
||||||
|
|
||||||
import json as json_module
|
import json as json_module
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from .parser import parse_regex, ParseError
|
from .parser import ASTNode, ParseError
|
||||||
from .converter import convert_to_english, convert_to_english_verbose
|
from .converter import convert_to_english, convert_to_english_verbose
|
||||||
from .examples import generate_examples
|
from .examples import generate_examples
|
||||||
from .flavors import (
|
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"Flavor: {result['flavor']}")
|
||||||
click.echo(f"\nDescription:\n{result['description']}")
|
click.echo(f"\nDescription:\n{result['description']}")
|
||||||
if result.get('structure'):
|
if result.get('structure'):
|
||||||
click.echo(f"\nStructure:")
|
click.echo("\nStructure:")
|
||||||
for item in result['structure']:
|
for item in result['structure']:
|
||||||
click.echo(f" - {item}")
|
click.echo(f" - {item}")
|
||||||
else:
|
else:
|
||||||
@@ -87,7 +88,7 @@ def explain(pattern: str, flavor: str, verbose: bool, output_format: str):
|
|||||||
|
|
||||||
warnings = get_compatibility_warnings(pattern, flavor)
|
warnings = get_compatibility_warnings(pattern, flavor)
|
||||||
if warnings:
|
if warnings:
|
||||||
click.echo(f"\nCompatibility warnings:")
|
click.echo("\nCompatibility warnings:")
|
||||||
for w in warnings:
|
for w in warnings:
|
||||||
click.echo(f" [{w.severity.upper()}] {w.feature}: {w.message}")
|
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:
|
else:
|
||||||
click.echo(f"\nPattern: {pattern}")
|
click.echo(f"\nPattern: {pattern}")
|
||||||
click.echo(f"Flavor: {flavor}")
|
click.echo(f"Flavor: {flavor}")
|
||||||
click.echo(f"\nMatching examples:")
|
click.echo("\nMatching examples:")
|
||||||
for i, example in enumerate(examples, 1):
|
for i, example in enumerate(examples, 1):
|
||||||
click.echo(f" {i}. {example}")
|
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']}")
|
click.echo(f"Flavor: {result['flavor']}")
|
||||||
|
|
||||||
if result.get('warnings'):
|
if result.get('warnings'):
|
||||||
click.echo(f"\nWarnings:")
|
click.echo("\nWarnings:")
|
||||||
for w in result['warnings']:
|
for w in result['warnings']:
|
||||||
click.echo(f" - {w}")
|
click.echo(f" - {w}")
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ def build(flavor: str):
|
|||||||
click.echo(f"Flavor: {flavor}")
|
click.echo(f"Flavor: {flavor}")
|
||||||
click.echo("Enter 'quit' to exit, 'back' to go back, 'done' when finished.\n")
|
click.echo("Enter 'quit' to exit, 'back' to go back, 'done' when finished.\n")
|
||||||
|
|
||||||
pattern_parts = []
|
pattern_parts: List[ASTNode] = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
current_pattern = "".join(p.to_regex() if hasattr(p, 'to_regex') else str(p) for p in pattern_parts)
|
current_pattern = "".join(p.to_regex() if hasattr(p, 'to_regex') else str(p) for p in pattern_parts)
|
||||||
|
|||||||
Reference in New Issue
Block a user