Fix year_low/year_high type annotations from int to Optional[int]#585
Open
chengjilai wants to merge 1 commit into
Open
Fix year_low/year_high type annotations from int to Optional[int]#585chengjilai wants to merge 1 commit into
chengjilai wants to merge 1 commit into
Conversation
The year_low and year_high parameters default to None and handle None values internally, but were annotated as int. This causes type checkers to incorrectly flag passing int | None values. Closes scholarly-python-package#584
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates type hints to explicitly allow None for year range parameters in scholarly search URL construction and publication searching.
Changes:
- Import
Optionalfromtyping. - Update
year_low/year_highannotations frominttoOptional[int]insearch_pubs. - Update
year_low/year_highannotations frominttoOptional[int]in_construct_url.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Fix outdated type annotations for
year_lowandyear_highparameters in_Scholarly.search_pubsand_Scholarly._construct_url. These parameters default toNoneand handleNonevalues internally (the code explicitly checksif year_low is not None), but were annotated asintinstead ofOptional[int].This causes type checkers (ty, mypy, pyright, etc.) to incorrectly report errors when callers pass
Noneorint | Nonevalues.Changes
year_low: int = None→year_low: Optional[int] = Noneyear_high: int = None→year_high: Optional[int] = NoneOptionalto the typing importssearch_pubsand_construct_urlhave been updatedCloses #584