build: update dependencies - #1139
Conversation
WalkthroughThe pull request updates Ruff lint rules and per-file exceptions, refines several runtime implementations, adjusts document permissions and serialization behavior, removes redundant returns and assignments, and adds role cleanup after deletion. Tests are aligned with changed exception and authorization behavior, identifier extraction coverage is added, fixtures and imports are cleaned up, and numerous test docstrings and whitespace sections are standardized. Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pyproject.toml`:
- Line 244: Resolve all A002 violations caused by enabling the “A” Ruff ruleset,
prioritizing renaming affected function parameters named file in harvest.py,
fixtures.py, and other occurrences while preserving call behavior; use narrowly
scoped lint exceptions only where renaming is impractical. Run uv run poe lint
and address any remaining violations.
In `@sonar/modules/cli/fixtures.py`:
- Around line 172-176: Update the attachment-loading loop around
db_record.add_file to resolve each record_file["path"] against directory, reject
candidates that resolve outside the fixture directory (including absolute paths
and traversal), and only open validated paths. Preserve the existing file check
and attachment behavior for paths contained within the fixture directory.
In `@sonar/modules/utils.py`:
- Around line 193-194: Update both exception-handling loops in is_ip_in_list and
get_ips_list to validate each ip_range is a string before evaluating membership
or parsing, so values such as None and integers are skipped as invalid entries.
Preserve the narrowed exception handling for parsing errors and do not restore a
blanket Exception handler.
In `@sonar/suggestions/rest.py`:
- Line 44: In the service-resolution fallback around sonar.service(resource) and
search_cls(...), replace the broad Exception handler with only the known
service-resolution or import-related exceptions. Preserve the
RECORDS_REST_ENDPOINTS fallback for those expected failures, while allowing
unexpected initialization or programming errors to propagate instead of becoming
a misleading 404.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b882bacb-1c14-432b-80b5-9f75b693859c
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (50)
pyproject.tomlsonar/heg/cli/harvest.pysonar/heg/serializers/schemas/medline.pysonar/modules/babel_extractors.pysonar/modules/cli/fixtures.pysonar/modules/documents/cli/oai.pysonar/modules/documents/dnb.pysonar/modules/documents/dojson/sru/model.pysonar/modules/documents/permissions.pysonar/modules/documents/serializers/json.pysonar/modules/documents/urn.pysonar/modules/organisations/api.pysonar/modules/permissions.pysonar/modules/swisscovery/rest.pysonar/modules/users/api.pysonar/modules/users/extensions/remove_roles.pysonar/modules/utils.pysonar/resources/projects/service.pysonar/suggestions/rest.pysonar/theme/views.pytests/api/collections/test_collections_documents_facets.pytests/api/collections/test_collections_files_permissions.pytests/api/deposits/test_deposits_files_permissions.pytests/api/documents/test_documents_ark.pytests/api/documents/test_documents_files_permissions.pytests/api/documents/test_documents_permissions.pytests/api/documents/test_documents_query.pytests/api/organisations/test_organisations_files_permissions.pytests/api/stats/test_stats_permissions.pytests/api/subdivisions/test_subdivisions_documents_facets.pytests/conftest.pytests/ui/collections/test_collections_view_permissions.pytests/ui/deposits/test_deposits_view_permissions.pytests/ui/documents/cli/test_documents_cli_ark.pytests/ui/documents/schemas/test_sru_schema.pytests/ui/documents/test_dc_schema.pytests/ui/documents/test_documents_dumpers.pytests/ui/documents/test_documents_receivers.pytests/ui/documents/test_documents_view_permissions.pytests/ui/documents/test_documents_views.pytests/ui/organisations/test_organisations_view_permissions.pytests/ui/projects/test_projects_api.pytests/ui/shibboleth_authenticator/test_shibboleth_auth.pytests/ui/test_permissions.pytests/ui/test_utils.pytests/ui/test_views.pytests/ui/users/test_users_cli.pytests/unit/documents/serializers/test_google_scholar_schema.pytests/unit/documents/serializers/test_schemaorg_schema.pytests/unit/resources/test_resources_api.py
💤 Files with no reviewable changes (22)
- tests/ui/documents/test_documents_view_permissions.py
- tests/ui/documents/test_documents_receivers.py
- sonar/modules/documents/dnb.py
- sonar/modules/users/extensions/remove_roles.py
- tests/ui/deposits/test_deposits_view_permissions.py
- tests/ui/documents/schemas/test_sru_schema.py
- tests/ui/documents/test_documents_dumpers.py
- sonar/modules/users/api.py
- tests/api/documents/test_documents_ark.py
- tests/api/organisations/test_organisations_files_permissions.py
- tests/ui/documents/cli/test_documents_cli_ark.py
- tests/ui/organisations/test_organisations_view_permissions.py
- sonar/modules/documents/serializers/json.py
- tests/api/documents/test_documents_permissions.py
- tests/ui/collections/test_collections_view_permissions.py
- tests/api/documents/test_documents_files_permissions.py
- tests/api/collections/test_collections_files_permissions.py
- sonar/modules/organisations/api.py
- sonar/heg/serializers/schemas/medline.py
- tests/api/deposits/test_deposits_files_permissions.py
- sonar/modules/documents/dojson/sru/model.py
- tests/ui/projects/test_projects_api.py
Adapt the configuration and the code to the new ruff default rule selection. * Drops the `D100`, `D200`, `D205` and `PERF203` ignores, without any violation left in the code base. * Fixes the violations behind the `D101`, `D103`, `D202`, `D400`, `F403`, `F405` and `F841` ignores and drops them as well. * Scopes `N815` to the marshmallow and serializer schemas, which mirror the camelCase fields of the JSON schemas. * Keeps `BLE001`, `D401`, `DTZ`, `RUF012` and `TRY002` ignored, as they cover deliberate patterns, and documents the reason of each ignore. * Removes dead variables in the DNB service, the documents serializer, the documents permissions and the suggestions REST module. * Replaces the star import of the utils tests by explicit imports. * Raises `TypeError` for an invalid argument type and catches only the netaddr errors in `is_ip_in_list()` and `get_ips_list()`. * Raises `RuntimeError` in the view generating an error for test purposes. * Renames the loop variables shadowing a fixture or an argument in the stats permissions tests and in the fixtures CLI. Updated dependencies (54 packages). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>
Adapt the configuration and the code to the new ruff default rule selection.
D100,D200,D205andPERF203ignores, without any violation left in the code base.D101,D103,D202,D400,F403,F405andF841ignores and drops them as well.N815to the marshmallow and serializer schemas, which mirror the camelCase fields of the JSON schemas.BLE001,D401,DTZ,RUF012andTRY002ignored, as they cover deliberate patterns, and documents the reason of each ignore.TypeErrorfor an invalid argument type and catches only the netaddr errors inis_ip_in_list()andget_ips_list().RuntimeErrorin the view generating an error for test purposes.Updated dependencies (54 packages).