internetarchive / internetarchive/openlibrary
Code complexity: `update_keys()` in `solr/update_work.py` is too complex
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 138
Description
A continuation of #7883
The `update_keys()` async function in `openlibrary/solr/update_work.py` is 145+ lines long and is too complex...
https://github.com/internetarchive/openlibrary/blob/112b89b2b5a37262664cd0f7647939a670e04833/openlibrary/solr/update_work.py#L1382-L1528
```
openlibrary/solr/update_work.py:1382:11: C901 `update_keys` is too complex (31 > 28)
openlibrary/solr/update_work.py:1382:11: PLR0912 Too many branches (24 > 22)
openlibrary/solr/update_work.py:1382:11: PLR0915 Too many statements (83 > 70)
```
Tasks:
* [ ] In a separate pull request, add ___a lot___ of tests for this function ___without___ modifying the function.
* [ ] ___After___ the first pull request has been merged, in a separate pull request:
* [ ] In `pyproject.toml` remove this line `"openlibrary/solr/update_work.py" = ["C901", "E722", "PLR0912", "PLR0915"]`
* [ ] Modify the `update_keys()` function so that it passes the tests created in step 1 as well as all `ruff` tests.
Contributor guide
Assessment
This issue has not been assessed yet.