From 2d21b92d4943d03f1a5446593e99859bc9db30f3 Mon Sep 17 00:00:00 2001 From: chenghjilai Date: Tue, 26 May 2026 22:06:37 +0800 Subject: [PATCH] Fix year_low/year_high type annotations from int to Optional[int] 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 #584 --- scholarly/_scholarly.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scholarly/_scholarly.py b/scholarly/_scholarly.py index de0035e..6eef664 100644 --- a/scholarly/_scholarly.py +++ b/scholarly/_scholarly.py @@ -7,7 +7,7 @@ import pprint import datetime import re -from typing import Dict, List, Union +from typing import Dict, List, Optional, Union from ._navigator import Navigator from ._proxy_generator import ProxyGenerator from dotenv import find_dotenv, load_dotenv @@ -90,8 +90,8 @@ def set_timeout(self, timeout: int): def search_pubs(self, query: str, patents: bool = True, - citations: bool = True, year_low: int = None, - year_high: int = None, sort_by: str = "relevance", + citations: bool = True, year_low: Optional[int] = None, + year_high: Optional[int] = None, sort_by: str = "relevance", include_last_year: str = "abstracts", start_index: int = 0)->_SearchScholarIterator: """Searches by query and returns a generator of Publication objects @@ -569,8 +569,8 @@ def download_mandates_csv(self, filename: str, overwrite: bool = False, # TODO: Make it a public method in v1.6 def _construct_url(self, baseurl: str, patents: bool = True, - citations: bool = True, year_low: int = None, - year_high: int = None, sort_by: str = "relevance", + citations: bool = True, year_low: Optional[int] = None, + year_high: Optional[int] = None, sort_by: str = "relevance", include_last_year: str = "abstracts", start_index: int = 0)-> str: """Construct URL from requested parameters."""