Repository navigation
Clean up leftovers and inconsistencies found in a project audit - #261
Merged
Merged
Conversation
- 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
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
This was referenced Nov 11, 2026
Fix the flake8 warnings and make the lint check strict
Don't show the e-mail address in the copyright line of the docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)(object)base classes, two-argumentsuper(), the__ne__methods (Python 3 derives the same result from__eq__) andJsonPatch.__nonzero__.DiffBuilder._insert_testno longer deep-copies the values of generatedtestoperations.from_diffhas 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)jsonpatchnever closed PATCH, and closed ORIGINAL only with--in-place, whilejsondiffclosed both inputs. Both now share one helper, which leaves stdin open.Tests
python tests.pyran the doctests ofjsonpatchtwice and only the classes in a hand-maintained list (nothing was missing from it). It now usesunittest.main()withload_tests. The test count goes from 360 to 353: the 7 doctests that were run twice.tests.jsis found independent of the working directory and read as UTF-8.ext_tests.py: remove the coverage report. It started afterjsonpatchwas imported, so it reported about 43% whatever was run, and was skipped when tests failed. Also remove the doctests, whichtests.pyruns.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: dropwheel, which nothing uses.Packaging and docs
setup.py: close the files it reads; drop thepackage_dataentry forrequirements.txt, which matched nothing.MANIFEST.in: the sdist contained the.rstfiles and tests, but not what is needed to use them. Adddoc/conf.py,doc/Makefile,doc/requirements.txt,requirements-dev.txtandmakefile.doc/tutorial.rstwas broken on PyPI), say how to run the tests, drop the note on expected failures.readthedocs.ioanddatatracker.ietf.orginstead of the hosts that redirect to them... mod-jsonpatch:was a comment, not a label; typos in the tutorial; remove the empty_staticdirectory, the reference to a missing_templatesdirectory,u''prefixes and the "One line description of project." placeholder fromconf.py.Verification
Run locally on Python 3.13:
coverage run tests.py(353 tests) andproperty_tests.py(25 tests) pass; coverage ofjsonpatch.pystays at 100%.HYPOTHESIS_PROFILE=thorough(5000 examples each).pytest,ext_tests.py tests.js, the flake8 gate,mypy.stubtest,mypyontypetests/usage.py,sphinx-build -Wandpython -m build+twine check --strictpass.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