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
8 changes: 4 additions & 4 deletions json5/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def _parse_args(host, argv):
'--no-quote-keys',
action='store_false',
dest='quote_keys',
help="don't quote object keys that are identifiers"
' (this is the default)',
help="don't quote object keys that are identifiers "
'(this is the default)',
)
parser.add_argument(
'--trailing-commas',
Expand All @@ -158,8 +158,8 @@ def _parse_args(host, argv):
'--no-trailing-commas',
dest='trailing_commas',
action='store_false',
help='do not add commas after the last item in '
'multi-line lists and objects',
help='do not add commas after the last item in multi-line lists '
'and objects',
)
parser.add_argument(
'--strict',
Expand Down
118 changes: 60 additions & 58 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,58 +1,76 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = [ "setuptools>=61" ]

[project]
name = "json5"
description = "A Python implementation of the JSON5 data format."
readme = "README.md"
keywords = [ "json5" ]
license = { file = "LICENSE" }
authors = [
{name = "Dirk Pranke", email = "dpranke@chromium.org"},
{ name = "Dirk Pranke", email = "dpranke@chromium.org" },
]
keywords = [ "json5" ]
license = {file = "LICENSE"}
readme = "README.md"
requires-python = '>= 3.8.0'
classifiers= [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
requires-python = ">=3.8.0"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dynamic = [ "version" ]

urls.Changelog = "https://github.com/dpranke/pyjson5/blob/master/README.md"
urls.Issues = "https://github.com/dpranke/pyjson5/issues"
urls.Repository = "https://github.com/dpranke/pyjson5"
scripts.pyjson5 = "json5.tool:main"

[dependency-groups]
# Note that not everything is guaranteed to work on 3.8.
dev = [
'build >= 1.2.2.post1; python_version < "3.9"',
'build >= 1.3.0; python_version >= "3.9"',
'coverage == 7.5.4; python_version < "3.9"',
'coverage == 7.8.0; python_version >= "3.9" and python_version < "3.10"',
'coverage >= 7.12.0; python_version >= "3.10"',
'mypy == 1.14.1; python_version < "3.9"',
'mypy >= 1.19.0; python_version >= "3.9"',
'pip >= 25.3; python_version >= "3.9"',
'pylint == 3.2.7; python_version < "3.9"',
'pylint == 3.3.6; python_version >= "3.9" and python_version < "3.10"',
'pylint >= 4.0.4; python_version >= "3.10"',
'ruff >= 0.14.7',
'twine == 6.1.0; python_version < "3.10"',
'twine >= 6.2.0; python_version >= "3.10"',
"build>=1.2.2.post1; python_version<'3.9'",
"build>=1.3; python_version>='3.9'",
"coverage==7.5.4; python_version<'3.9'",
"coverage==7.8; python_version>='3.9' and python_version<'3.10'",
"coverage>=7.12; python_version>='3.10'",
"mypy==1.14.1; python_version<'3.9'",
"mypy>=1.19; python_version>='3.9'",
"pip>=25.3; python_version>='3.9'",
"pylint==3.2.7; python_version<'3.9'",
"pylint==3.3.6; python_version>='3.9' and python_version<'3.10'",
"pylint>=4.0.4; python_version>='3.10'",
"ruff>=0.14.7",
"twine==6.1; python_version<'3.10'",
"twine>=6.2; python_version>='3.10'",
]

[project.urls]
Repository = "https://github.com/dpranke/pyjson5"
Issues = "https://github.com/dpranke/pyjson5/issues"
Changelog = "https://github.com/dpranke/pyjson5/blob/master/README.md"
[tool.setuptools]
packages = [ "json5" ]

[project.scripts]
pyjson5 = "json5.tool:main"
[tool.setuptools.dynamic]
version = { attr = "json5.__version__" }

[tool.uv]
# 0.9.0 is the first version supporting Python 3.14
required-version = ">=0.9.0"

# By default, do not install/resolve to packages published within
# the past 30 days; this gives us some protection against automatically
# upgrading to a package that might have been newly compromised.
exclude-newer = "30 days"

[tool.ruff]
line-length = 79

include = [ "*/*.py", "run" ]
format.quote-style = "single"

[tool.pylint.basic]

Expand Down Expand Up @@ -98,24 +116,8 @@ disable = [
[tool.pylint.reports]
reports = "no"
score = "no"
[tool.ruff]
include = [ "run", "*/*.py" ]
line-length = 79

[tool.ruff.format]
quote-style = "single"

[tool.setuptools]
packages = [ "json5" ]

[tool.setuptools.dynamic]
version = {attr = "json5.__version__"}

[tool.uv]
# 0.9.0 is the first version supporting Python 3.14
required-version = ">=0.9.0"

# By default, do not install/resolve to packages published within
# the past 30 days; this gives us some protection against automatically
# upgrading to a package that might have been newly compromised.
exclude-newer = "30 days"
[tool.pyproject-fmt]
indent = 4
keep_full_version = true
max_supported_python = "3.14"
43 changes: 36 additions & 7 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class Runner:
subp.set_defaults(func=lambda _: method())
return subp

def call(self, *args, **kwargs):
cmd = shlex.join(*args)
def call(self, args, exit_on_error=True, **kwargs):
cmd = shlex.join(args)
if self.args.no_execute or self.args.verbose:
print(f'{cmd}')
if self.args.no_execute:
Expand All @@ -59,13 +59,16 @@ class Runner:
del kwargs['capture_output']

proc = subprocess.run(
*args, capture_output=capture_output, check=False, **kwargs
args, capture_output=capture_output, check=False, **kwargs
)
if proc.returncode != 0:
if self.args.quiet:
print(proc.stdout)
print(proc.stderr, file=sys.stderr)
sys.exit(proc.returncode)
if proc.stdout:
print(proc.stdout)
if proc.stderr:
print(proc.stderr, file=sys.stderr)
if exit_on_error:
sys.exit(proc.returncode)
return proc

def main(self, argv):
Expand Down Expand Up @@ -101,7 +104,8 @@ class Runner:
)

subp = self.add_parser(
'format', help='Format the source code with ruff.'
'format',
help='Format the source code with ruff and pyproject-fmt.',
)
subp.add_argument(
'--check',
Expand Down Expand Up @@ -271,6 +275,31 @@ class Runner:
print('Run `source .venv/bin/activate` to finish devenv setup.')

def run_format(self):
cmd = [
self.uv_path,
'run',
'pyproject-fmt',
'--column-width',
'80',
'--no-print-diff',
'pyproject.toml',
]

if self.args.check:
cmd.append('--check')
else:
cmd.append('--stdout')
proc = self.call(cmd, exit_on_error=False, capture_output=True)
if self.args.check and proc.returncode:
print('pyproject.toml needs formatting')
elif proc.returncode and not proc.stdout:
sys.exit(proc.returncode)
if not self.args.check and not self.args.no_execute:
with open('pyproject.toml') as fp:
orig_file = fp.read()
if proc.stdout != 'no change for pyproject.toml\n'.encode('utf8'):
with open('pyproject.toml', 'wb') as fp:
fp.write(proc.stdout)
cmd = self.run_cmd + ['-m', 'ruff', 'format']
if self.args.check:
cmd.append('--check')
Expand Down
Loading