Skip to content

Clean up leftovers and inconsistencies found in a project audit - #261

Merged
stefankoegl merged 8 commits into
masterfrom
claude/inspiring-turing-zftuu5
Nov 11, 2026
Merged

stefankoegl merged 8 commits into
masterfrom
claude/inspiring-turing-zftuu5

Conversation

@stefankoegl

Copy link
Copy Markdown
Owner

Result of reading the whole project for things that are broken, inconsistent, inefficient or no longer needed. This PR contains only the fixes that are safe; everything that needs a decision is listed in the session, not changed here.

Four commits, one per area.

Library (jsonpatch.py, stubs)

  • Remove Python 2 leftovers: coding line, (object) base classes, two-argument super(), the __ne__ methods (Python 3 derives the same result from __eq__) and JsonPatch.__nonzero__.
  • DiffBuilder._insert_test no longer deep-copies the values of generated test operations. from_diff has copied every operation of the patch since 2e37755, so these were copied twice.

Visible change: JsonPatch.__nonzero__ is gone. Nothing calls it on Python 3; bool(patch) is unaffected.

Command line (jsonpatch_cli.py)

  • jsonpatch never closed PATCH, and closed ORIGINAL only with --in-place, while jsondiff closed both inputs. Both now share one helper, which leaves stdin open.
  • Fix the tab, trailing whitespace and blank lines flake8 reported.

Tests

  • python tests.py ran the doctests of jsonpatch twice and only the classes in a hand-maintained list (nothing was missing from it). It now uses unittest.main() with load_tests. The test count goes from 360 to 353: the 7 doctests that were run twice.
  • tests.js is found independent of the working directory and read as UTF-8.
  • ext_tests.py: remove the coverage report. It started after jsonpatch was imported, so it reported about 43% whatever was run, and was skipped when tests failed. Also remove the doctests, which tests.py runs.
  • property_tests.py: no property is an expected failure any more, but the module still worked around them. Drop the "safe" documents without - keys and the test that only differed in using them, and let the state machine replace - members and test values that are equal in Python but not in JSON.
  • requirements-dev.txt: drop wheel, which nothing uses.

Packaging and docs

  • setup.py: close the files it reads; drop the package_data entry for requirements.txt, which matched nothing.
  • MANIFEST.in: the sdist contained the .rst files and tests, but not what is needed to use them. Add doc/conf.py, doc/Makefile, doc/requirements.txt, requirements-dev.txt and makefile.
  • README: fix the doubled slash in the badge links, link the tutorial on Read the Docs instead of "See source code for examples" (the relative link to doc/tutorial.rst was broken on PyPI), say how to run the tests, drop the note on expected failures.
  • Use readthedocs.io and datatracker.ietf.org instead of the hosts that redirect to them.
  • Docs: .. mod-jsonpatch: was a comment, not a label; typos in the tutorial; remove the empty _static directory, the reference to a missing _templates directory, u'' prefixes and the "One line description of project." placeholder from conf.py.

Verification

Run locally on Python 3.13:

  • coverage run tests.py (353 tests) and property_tests.py (25 tests) pass; coverage of jsonpatch.py stays at 100%.
  • The property tests whose inputs were widened pass with HYPOTHESIS_PROFILE=thorough (5000 examples each).
  • pytest, ext_tests.py tests.js, the flake8 gate, mypy.stubtest, mypy on typetests/usage.py, sphinx-build -W and python -m build + twine check --strict pass.
  • The wheel has the same files as before; the only metadata change is the documentation URL. Tests and the docs build also pass from the unpacked sdist.

Not checked: the two new Read the Docs links in the README (/en/latest/tutorial.html), as the sandbox could not reach the site. They follow the standard URL layout.


Generated by Claude Code

- drop the coding line, explicit object base classes and two-argument super()
- drop JsonPatch.__nonzero__, which only Python 2 used
- drop the __ne__ methods; Python 3 derives the same result from __eq__
- don't deep-copy the values of generated test operations in DiffBuilder:
  from_diff copies all operations of the patch since 2e37755, so they
  were copied twice

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PewzpjVeke4LTQ7Q88nyu6
jsondiff closed its inputs, but jsonpatch never closed PATCH, and closed
ORIGINAL only with --in-place. Both now use the same helper, which leaves
stdin open. Also fixes a tab, trailing whitespace and blank lines that
flake8 reported.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PewzpjVeke4LTQ7Q88nyu6
- setup.py: close the files it reads, drop the package_data entry for
  requirements.txt, which matched nothing as there is no such package
- MANIFEST.in: ship doc/conf.py, doc/Makefile, doc/requirements.txt,
  requirements-dev.txt and the makefile, so that the docs, which the
  sdist already contained, can be built from it, and its tests be run
- README: fix the doubled slash in the badge links, link the tutorial on
  Read the Docs instead of pointing to the source code (the relative link
  to doc/tutorial.rst was broken on PyPI), say how to run the tests, and
  drop the note on expected failures, of which there are none any more
- use readthedocs.io and datatracker.ietf.org, where the old hosts
  redirect to
- doc: fix the mod-jsonpatch label, which was a comment, and typos in the
  tutorial; remove the empty _static directory, the missing _templates
  directory, u'' prefixes and the placeholder description from conf.py

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PewzpjVeke4LTQ7Q88nyu6
- tests.py: 'python tests.py' ran the doctests of jsonpatch twice, and
  only the test classes in a hand-maintained list. It now uses
  unittest.main() with load_tests, which finds all classes. tests.js is
  found independent of the working directory and read as UTF-8
- ext_tests.py: remove the coverage report, which was started after
  jsonpatch was imported and so reported meaningless numbers, and was
  skipped when tests failed; remove the doctests, which tests.py runs
- property_tests.py: no property is an expected failure any more, so
  drop the 'safe' documents without '-' keys and the test that only
  differed in using them, and let the state machine replace '-' members
  and test values that are equal in Python but not in JSON
- requirements-dev.txt: drop wheel, which nothing uses

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PewzpjVeke4LTQ7Q88nyu6
@coveralls

coveralls commented Nov 10, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — claude/inspiring-turing-zftuu5 into master

The copyright notice was set to __author__, which includes the e-mail
address, so every page of the documentation showed it in its footer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PewzpjVeke4LTQ7Q88nyu6
CI ran flake8 twice: once for syntax errors and undefined names, and once
with --exit-zero for everything else, so about 270 style warnings, nearly
all of them in tests.py and doc/conf.py, never failed a build. They are
fixed, most of them with autopep8, without changing what the code does.
Apart from whitespace and comments, the only changes are a renamed
variable and dropped u'' prefixes in two tests, and 'import sys, os'
split in two in doc/conf.py.

The check is now a single strict run, configured in .flake8 so that it
gives the same result locally. It no longer passes --max-complexity=10,
which three functions exceed (patch_files, AppendOperation._apply and
JsonPatch.apply): splitting them up is not a style fix.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PewzpjVeke4LTQ7Q88nyu6
Fix the flake8 warnings and make the lint check strict
Don't show the e-mail address in the copyright line of the docs
@stefankoegl
stefankoegl merged commit f54a754 into master Nov 11, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants