Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove circular reference check on item metadata hashing #639

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ jobs:
max-parallel: 1 # Avoid timeout errors
matrix:
python: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
envname: ['py'] # To allow testing more special configurations below
include:
- { python: '3.12', envname: 'py312ujson' } # With optional ujson dependency
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- run: pip install tox
- run: tox -e py
- run: tox -e ${{ matrix.envname }}
3 changes: 1 addition & 2 deletions internetarchive/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ def __hash__(self) -> int:
without_excluded_keys = {
k: v for k, v in self.item_metadata.items()
if k not in self.EXCLUDED_ITEM_METADATA_KEYS}
return hash(json.dumps(without_excluded_keys,
sort_keys=True, check_circular=False)) # type: ignore
return hash(json.dumps(without_excluded_keys, sort_keys=True)) # type: ignore


class Item(BaseItem):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,7 @@ def test_modify_metadata(nasa_item, nasa_metadata):
secret_key='b')
# Test that item re-initializes
assert nasa_item.metadata['title'] == 'new title'


def test_hash_item(nasa_metadata, nasa_item, session):
assert hash(nasa_item)
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,py39,py310,py311,py312,pypy39,pypy310
envlist = py38,py39,py310,py311,py312,py312ujson,pypy39,pypy310

[testenv]
deps = -r tests/requirements.txt
Expand All @@ -21,3 +21,8 @@ basepython=python3.11

[testenv:py312]
basepython=python3.12

[testenv:py312ujson]
basepython=python3.12
deps = -r tests/requirements.txt
ujson