Add CROSSREF_MODE=local support via LocalCrossrefAdapter#1095
Merged
Conversation
- Extract _CrossrefHttpClient wrapping the existing aiohttp logic - Add module-level create_crossref_client() factory: returns LocalCrossrefAdapter when CROSSREF_MODE=local, otherwise the HTTP client - _search_by_issn() now delegates to the factory instead of calling _get_journal_by_issn() directly - aletheia-crossref-adapter is an optional dependency; ImportError is raised with a clear message if CROSSREF_MODE=local but the package is not installed
- Add dict[str, str] type params to _CrossrefHttpClient.__init__ headers - Add return type annotation to create_crossref_client factory function - Add explicit result type annotation to suppress no-any-return error - Add mypy ignore_missing_imports override for aletheia_crossref_adapter
florath
approved these changes
Mar 16, 2026
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.
Summary
_CrossrefHttpClientwrapping the existing aiohttp logiccreate_crossref_client()factory: returnsLocalCrossrefAdapterwhenCROSSREF_MODE=local, otherwise the live HTTP client_search_by_issn()delegates to the factory instead of calling_get_journal_by_issn()directlyaletheia-crossref-adapteris optional; a clearImportErroris raised ifCROSSREF_MODE=localbut the package is not installedInstallation
Usage
Test plan
tests/unit/backends/test_crossref_analyzer.pypasses (remote mode unchanged)CROSSREF_MODE=localroutes throughLocalCrossrefAdapterCROSSREF_MODE=localwithout adapter installed raises clearImportError