freelawproject / eyecite

Find legal citations in any block of text
https://freelawproject.github.io/eyecite/
BSD 2-Clause "Simplified" License
114 stars 27 forks source link

Hash function raises unexpected json error #167

Closed cbrew closed 4 months ago

cbrew commented 4 months ago

Easy to fix. The hash function at the end of utils calls json.dumps, which does not handle datetime values.

Pull request coming.

import eyecite small = '25 Texas L.Rev. 199' cit = eyecite.get_citations(small) hash(cit[0])

mattdahl commented 4 months ago

Thank you, this is an alarming bug... It seems that our test_factories.journal_citation() function does not mock citations with a realistic all_editions field (which should have datetime stuff), so this was not caught in our tests. That seems like a problem in and of itself, but, separately, the utils.hash_sha256() function does need to handle non-serializable types... Thanks for the PR.

cbrew commented 4 months ago

the change is really simple, add default=str to the json.dumps call in utils.hash_sha256().

Making a pull request is harder than I thought, because of lint checks and all that. Working on it slowly.