Skip to content

Fix year_low/year_high type annotations from int to Optional[int]#585

Open
chengjilai wants to merge 1 commit into
scholarly-python-package:developfrom
chengjilai:fix/year-low-high-optional-types
Open

Fix year_low/year_high type annotations from int to Optional[int]#585
chengjilai wants to merge 1 commit into
scholarly-python-package:developfrom
chengjilai:fix/year-low-high-optional-types

Conversation

@chengjilai
Copy link
Copy Markdown

Summary

Fix outdated type annotations for year_low and year_high parameters in _Scholarly.search_pubs and _Scholarly._construct_url. These parameters default to None and handle None values internally (the code explicitly checks if year_low is not None), but were annotated as int instead of Optional[int].

This causes type checkers (ty, mypy, pyright, etc.) to incorrectly report errors when callers pass None or int | None values.

Changes

  • Changed year_low: int = Noneyear_low: Optional[int] = None
  • Changed year_high: int = Noneyear_high: Optional[int] = None
  • Added Optional to the typing imports
  • Both search_pubs and _construct_url have been updated

Closes #584

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
Copilot AI review requested due to automatic review settings May 26, 2026 14:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Optional from typing.
  • Update year_low/year_high annotations from int to Optional[int] in search_pubs.
  • Update year_low/year_high annotations from int to Optional[int] in _construct_url.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants