fix: resolve CI/CD test and lint failures
This commit is contained in:
@@ -20,7 +20,7 @@ from .type_check import validate_types, infer_schema_from_data
|
||||
def find_files(
|
||||
pattern: str,
|
||||
recursive: bool = False,
|
||||
directory: Optional[str] = None,
|
||||
directory: Optional[str] = None
|
||||
) -> List[str]:
|
||||
"""Find files matching a pattern."""
|
||||
search_dir = directory or "."
|
||||
@@ -39,7 +39,7 @@ def resolve_format(fmt: Optional[str], file_path: str) -> str:
|
||||
if fmt not in SUPPORTED_FORMATS:
|
||||
raise click.BadParameter(
|
||||
f"Unsupported format: {fmt}. Supported: {', '.join(SUPPORTED_FORMATS)}",
|
||||
param_hint="--format",
|
||||
param_hint="--format"
|
||||
)
|
||||
return fmt
|
||||
return detect_format(file_path)
|
||||
@@ -48,16 +48,8 @@ def resolve_format(fmt: Optional[str], file_path: str) -> str:
|
||||
@click.command()
|
||||
@click.argument("input_file", type=click.Path(exists=True))
|
||||
@click.argument("output_file", type=click.Path())
|
||||
@click.option(
|
||||
"--from", "-f", "from_format", help="Input format (json, yaml, toml)"
|
||||
)
|
||||
@click.option(
|
||||
"--to",
|
||||
"-t",
|
||||
"to_format",
|
||||
required=True,
|
||||
help="Output format (json, yaml, toml)",
|
||||
)
|
||||
@click.option("--from", "-f", "from_format", help="Input format (json, yaml, toml)")
|
||||
@click.option("--to", "-t", "to_format", required=True, help="Output format (json, yaml, toml)")
|
||||
@click.option("--indent", "-i", default=2, help="Indentation spaces (0 for compact)")
|
||||
@click.option("--quiet", "-q", is_flag=True, help="Minimal output")
|
||||
def convert(
|
||||
@@ -66,7 +58,7 @@ def convert(
|
||||
from_format: Optional[str],
|
||||
to_format: str,
|
||||
indent: int,
|
||||
quiet: bool,
|
||||
quiet: bool
|
||||
) -> None:
|
||||
"""Convert a file from one format to another.
|
||||
|
||||
@@ -78,12 +70,11 @@ def convert(
|
||||
if to_format not in SUPPORTED_FORMATS:
|
||||
raise click.BadParameter(
|
||||
f"Unsupported format: {to_format}. Supported: {', '.join(SUPPORTED_FORMATS)}",
|
||||
param_hint="--to",
|
||||
param_hint="--to"
|
||||
)
|
||||
|
||||
if input_file == "-":
|
||||
import sys
|
||||
|
||||
content = sys.stdin.read()
|
||||
input_format = from_format or "json"
|
||||
data = load_data(content, input_format)
|
||||
@@ -96,7 +87,6 @@ def convert(
|
||||
|
||||
if output_file == "-":
|
||||
import sys
|
||||
|
||||
sys.stdout.write(result)
|
||||
else:
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
@@ -111,24 +101,11 @@ def convert(
|
||||
|
||||
@click.command()
|
||||
@click.argument("input_files", nargs=-1, type=click.Path(exists=True))
|
||||
@click.option(
|
||||
"--from", "-f", "from_format", help="Input format (json, yaml, toml)"
|
||||
)
|
||||
@click.option(
|
||||
"--to",
|
||||
"-t",
|
||||
"to_format",
|
||||
required=True,
|
||||
help="Output format (json, yaml, toml)",
|
||||
)
|
||||
@click.option("--from", "-f", "from_format", help="Input format (json, yaml, toml)")
|
||||
@click.option("--to", "-t", "to_format", required=True, help="Output format (json, yaml, toml)")
|
||||
@click.option("--output-dir", "-o", default=".", help="Output directory for converted files")
|
||||
@click.option("--indent", "-i", default=2, help="Indentation spaces")
|
||||
@click.option(
|
||||
"--pattern",
|
||||
"-p",
|
||||
default="*.{json,yaml,yml,toml}",
|
||||
help="File pattern for batch processing",
|
||||
)
|
||||
@click.option("--pattern", "-p", default="*.{json,yaml,yml,toml}", help="File pattern for batch processing")
|
||||
@click.option("--recursive", "-r", is_flag=True, help="Search recursively")
|
||||
@click.option("--quiet", "-q", is_flag=True, help="Minimal output")
|
||||
def batch_convert(
|
||||
@@ -139,7 +116,7 @@ def batch_convert(
|
||||
indent: int,
|
||||
pattern: str,
|
||||
recursive: bool,
|
||||
quiet: bool,
|
||||
quiet: bool
|
||||
) -> None:
|
||||
"""Convert multiple files from one format to another.
|
||||
|
||||
@@ -149,7 +126,7 @@ def batch_convert(
|
||||
if to_format not in SUPPORTED_FORMATS:
|
||||
raise click.BadParameter(
|
||||
f"Unsupported format: {to_format}. Supported: {', '.join(SUPPORTED_FORMATS)}",
|
||||
param_hint="--to",
|
||||
param_hint="--to"
|
||||
)
|
||||
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
@@ -196,7 +173,7 @@ def validate(
|
||||
input_file: str,
|
||||
schema_file: Optional[str],
|
||||
strict: bool,
|
||||
quiet: bool,
|
||||
quiet: bool
|
||||
) -> None:
|
||||
"""Validate a file against a JSON Schema.
|
||||
|
||||
@@ -205,7 +182,6 @@ def validate(
|
||||
try:
|
||||
if input_file == "-":
|
||||
import sys
|
||||
|
||||
content = sys.stdin.read()
|
||||
input_format = "json"
|
||||
data = load_data(content, input_format)
|
||||
@@ -221,9 +197,7 @@ def validate(
|
||||
if not quiet:
|
||||
for error in validator.get_error_messages(errors):
|
||||
click.echo(error)
|
||||
raise click.ClickException(
|
||||
f"Validation failed with {len(errors)} error(s)"
|
||||
)
|
||||
raise click.ClickException(f"Validation failed with {len(errors)} error(s)")
|
||||
else:
|
||||
if not quiet:
|
||||
click.echo("Validation passed")
|
||||
@@ -237,15 +211,8 @@ def validate(
|
||||
|
||||
@click.command()
|
||||
@click.argument("input_files", nargs=-1, type=click.Path(exists=True))
|
||||
@click.option(
|
||||
"--schema", "-s", "schema_file", required=True, help="Path to JSON Schema file"
|
||||
)
|
||||
@click.option(
|
||||
"--pattern",
|
||||
"-p",
|
||||
default="*.{json,yaml,yml,toml}",
|
||||
help="File pattern for batch processing",
|
||||
)
|
||||
@click.option("--schema", "-s", "schema_file", required=True, help="Path to JSON Schema file")
|
||||
@click.option("--pattern", "-p", default="*.{json,yaml,yml,toml}", help="File pattern for batch processing")
|
||||
@click.option("--recursive", "-r", is_flag=True, help="Search recursively")
|
||||
@click.option("--quiet", "-q", is_flag=True, help="Minimal output")
|
||||
def batch_validate(
|
||||
@@ -253,7 +220,7 @@ def batch_validate(
|
||||
schema_file: str,
|
||||
pattern: str,
|
||||
recursive: bool,
|
||||
quiet: bool,
|
||||
quiet: bool
|
||||
) -> None:
|
||||
"""Validate multiple files against a JSON Schema.
|
||||
|
||||
@@ -301,9 +268,7 @@ def batch_validate(
|
||||
click.echo(f"Valid: {valid_count}, Invalid: {invalid_count}", err=True)
|
||||
|
||||
if invalid_count > 0:
|
||||
raise click.ClickException(
|
||||
f"Validation failed for {invalid_count} file(s)"
|
||||
)
|
||||
raise click.ClickException(f"Validation failed for {invalid_count} file(s)")
|
||||
|
||||
except Exception as e:
|
||||
raise click.ClickException(str(e))
|
||||
@@ -316,7 +281,7 @@ def batch_validate(
|
||||
def typecheck(
|
||||
input_file: str,
|
||||
infer: bool,
|
||||
quiet: bool,
|
||||
quiet: bool
|
||||
) -> None:
|
||||
"""Check types in a data file.
|
||||
|
||||
@@ -325,7 +290,6 @@ def typecheck(
|
||||
try:
|
||||
if input_file == "-":
|
||||
import sys
|
||||
|
||||
content = sys.stdin.read()
|
||||
input_format = "json"
|
||||
data = load_data(content, input_format)
|
||||
@@ -337,7 +301,6 @@ def typecheck(
|
||||
schema = infer_schema_from_data(data)
|
||||
if not quiet:
|
||||
import json
|
||||
|
||||
click.echo(json.dumps(schema, indent=2))
|
||||
else:
|
||||
if not quiet:
|
||||
|
||||
Reference in New Issue
Block a user