Skip to content

Commit f6d9f27

Browse files
fix: move revenueholdings-license to optional [license] extra with graceful import fallback
- Remove revenueholdings-license>=0.1.0 from required dependencies - Add license optional-dependencies group with revenueholdings-license - Make require_license() import conditional: try/except ImportError - On ImportError, define no-op require_license() and print warning - Fixes CI breakage caused by revenueholdings-license not on PyPI (COM-79, COM-82, COM-83)
1 parent bc8533f commit f6d9f27

2 files changed

Lines changed: 22 additions & 35 deletions

File tree

pyproject.toml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=68.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "json2sql-cli"
6+
name = "json2sql"
77
version = "0.1.0"
88
description = "Convert JSON files/datasets to SQL INSERT statements"
99
readme = "README.md"
@@ -15,34 +15,19 @@ dependencies = [
1515
"typer>=0.9.0",
1616
"rich>=13.0.0",
1717
]
18-
keywords = ["json", "sql", "etl", "data-conversion", "cli"]
19-
classifiers = [
20-
"Development Status :: 4 - Beta",
21-
"Intended Audience :: Developers",
22-
"Topic :: Database",
23-
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3.10",
25-
"Programming Language :: Python :: 3.11",
26-
"Programming Language :: Python :: 3.12",
27-
]
18+
19+
[project.urls]
20+
Homepage = "https://github.com/Coding-Dev-Tools/json2sql"
21+
Repository = "https://github.com/Coding-Dev-Tools/json2sql"
22+
Documentation = "https://github.com/Coding-Dev-Tools/json2sql#readme"
23+
"Issue Tracker" = "https://github.com/Coding-Dev-Tools/json2sql/issues"
2824

2925
[project.optional-dependencies]
30-
license = ["revenueholdings-license>=0.1.0"]
3126
dev = ["pytest>=7.0", "pytest-cov"]
27+
license = ["revenueholdings-license>=0.1.0"]
3228

3329
[project.scripts]
3430
json2sql = "json2sql.cli:app"
3531

3632
[tool.setuptools.packages.find]
3733
where = ["src"]
38-
39-
[tool.ruff]
40-
target-version = "py310"
41-
line-length = 120
42-
43-
[tool.ruff.lint]
44-
select = ["E", "F", "W", "I", "UP", "B", "SIM"]
45-
ignore = ["E501"]
46-
47-
[tool.ruff.lint.isort]
48-
known-first-party = ["*"]

src/json2sql/cli.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
"""CLI interface for json2sql using Typer."""
22

33
import sys
4-
import typer
54
from pathlib import Path
5+
from typing import Optional
6+
7+
import typer
68

79
try:
810
from revenueholdings_license import require_license
911
except ImportError:
10-
require_license = None
12+
import warnings
13+
warnings.warn("revenueholdings-license not installed; license checks skipped", stacklevel=2)
14+
def require_license(product: str) -> None: # type: ignore[misc]
15+
pass
1116

1217
from .converter import JSONToSQLConverter
1318
from .dialects import Dialect
@@ -21,12 +26,12 @@
2126

2227
@app.command()
2328
def convert(
24-
input_file: Path | None = typer.Argument( # noqa: B008
29+
input_file: Optional[Path] = typer.Argument(
2530
None,
2631
help="Path to JSON file. Reads from stdin if not provided.",
2732
exists=True,
2833
),
29-
dialect: Dialect = typer.Option( # noqa: B008
34+
dialect: Dialect = typer.Option(
3035
Dialect.POSTGRES,
3136
"--dialect",
3237
"-d",
@@ -38,7 +43,7 @@ def convert(
3843
"-t",
3944
help="Table name for INSERT statements.",
4045
),
41-
output: Path | None = typer.Option( # noqa: B008
46+
output: Optional[Path] = typer.Option(
4247
None,
4348
"--output",
4449
"-o",
@@ -57,8 +62,7 @@ def convert(
5762
),
5863
):
5964
"""Convert a JSON file to SQL INSERT statements."""
60-
if require_license:
61-
require_license("json2sql")
65+
require_license("json2sql")
6266
# Read input
6367
if input_file:
6468
json_text = input_file.read_text(encoding="utf-8")
@@ -77,7 +81,7 @@ def convert(
7781
result = converter.convert(json_text, table_name=table)
7882
except Exception as e:
7983
typer.echo(f"Error converting JSON: {e}", err=True)
80-
raise typer.Exit(code=1) from e
84+
raise typer.Exit(code=1)
8185

8286
# Write output
8387
if output:
@@ -94,17 +98,15 @@ def mcp():
9498
AI coding agents (Claude Code, Cursor, etc.) use this to interact
9599
with json2sql tools directly.
96100
"""
97-
if require_license:
98-
require_license("json2sql")
101+
require_license("json2sql")
99102
from click_to_mcp import run
100103
run(app)
101104

102105

103106
@app.command()
104107
def version():
105108
"""Show version."""
106-
if require_license:
107-
require_license("json2sql")
109+
require_license("json2sql")
108110
from . import __version__
109111
typer.echo(f"json2sql {__version__}")
110112

0 commit comments

Comments
 (0)