Skip to content

Fix type annotations for year_low/year_high parameters (int -> Optional[int]) #584

Description

@chengjilai

The year_low and year_high parameters in search_pubs and _construct_url are annotated as int but default to None, which means they should be Optional[int].

Affected methods:

  • _Scholarly.search_pubs (scholarly/_scholarly.py:93-94)
  • _Scholarly._construct_url (scholarly/_scholarly.py:572-573)

This causes type checkers (e.g., ty, mypy, pyright) to incorrectly flag passing None or int | None values as invalid:

error[invalid-argument-type]: Argument to bound method search_pubs is incorrect
  year_low=...,  Expected `int`, found `int | None`

The code already handles None internally (lines 579-580 check if year_low is not None), so the fix is simply to update the annotations to Optional[int].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions