Name the match key constants after the match key - #71
Merged
Conversation
The rename of the FodId hash to the match key left the two constants naming that field still called HASH_OFFSET and HASH_LENGTH, even though their own comments already said match key. They are now MATCH_KEY_OFFSET and MATCH_KEY_LENGTH, holding the same values of 5 and 32, and HEADER_LENGTH and PAYLOAD_LENGTH are worked out from the new names whilst keeping the names they already had. HASH_OFFSET and HASH_LENGTH stay as deprecated aliases of the new constants so that code outside this repository keeps working, matching the deprecated hash property that already stands beside match_key. A class constant cannot warn when it is read, so the aliases carry the same wording as that property in a comment instead. Every use inside the repository now reads the new names, covering the reader, the client, the tests, the test helpers and the example, and a new test checks that each alias still holds the value of the constant it points at. Nothing to do with SHA-256 hashing itself was renamed. Verified with the package tests, 145 passed and 2 skipped, the two skips being the live cloud tests that need a resource key.
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.
The problem
Pull request #69 renamed the stable, comparable part of a 51Did from the hash to the match key, giving
FodIdamatch_keyattribute and leavinghashbehind as a deprecated property that warns. The two constants naming that same field in the payload were not renamed, sofod_id.pystill declared this.Their own comments already read "Byte offset of the match key field" and "Byte length of the match key field", so anyone reading the class met one vocabulary in the comments and the older one in the names.
What changed
MATCH_KEY_OFFSETandMATCH_KEY_LENGTHare now the real constants infod_id.py, holding the same values of 5 and 32 and keeping the comments they already had.HEADER_LENGTHandPAYLOAD_LENGTHare worked out from the new names. Their own names do not change, because they name the header and the payload rather than the match key.fod_id.py, the clientdid_client.py, the teststest_fodid.pyandtest_did_client.py, the test helperenvelope.pyand the examplefodid_example.py. That is 30 uses, plus the two declarations themselves.test_deprecated_constant_aliases_hold_the_new_values, checks that each old name still holds the value of the constant it points at.hashproperty.HASHED_EMAIL,IdType.HASHED_EMAILand the descriptions of the SHA-256 match key all stand as they were.Why the alias is kept
HASH_OFFSETandHASH_LENGTHremain as deprecated aliases pointing at the new constants, so code outside this repository that reads them keeps working through this release, exactly as the deprecatedhashproperty keeps working besidematch_key. The property warns withDeprecationWarningwhen it is read, which a plain class constant cannot do, so the aliases carry the same wording as that property in a comment saying they are deprecated, that the field is now called the match key after the Model Terms for Marketing vocabulary, and that they will be removed in a future release.How it was verified
The package tests were run in a clean virtual environment on Python 3.14.5, with the OWID source taken from the
owid-pythonsubmodule the wayci/copy-owid-source.ps1andtox.inido it.The two skips are the live cloud tests, which need a resource key that was not set, and they were skipped on this branch as they are on
main.The example was run as well, so the change is exercised outside the tests.
A search of the whole working copy for the old names now returns only the two alias declarations.
Produced with AI assistance under James Rosewell's direction and needs human review.