Skip to content

Add overload to JIRA.search_issues() for better return type hinting #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3024,6 +3024,32 @@ def resolution(self, id: str) -> Resolution:

# Search

@overload
def search_issues(
self,
jql_str: str,
startAt: int,
maxResults: int,
validate_query: bool,
fields: Optional[Union[str, list[str]]],
expand: Optional[str],
json_result: Literal[False],
) -> ResultList[Issue]:
...

@overload
def search_issues(
self,
jql_str: str,
startAt: int,
maxResults: int,
validate_query: bool,
Comment on lines +3044 to +3046
Copy link
Contributor

Choose a reason for hiding this comment

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

Let me know if you figure out how to do this so mypy is happy.

I believe it was this issue I was running into when I first started adding typehints for these chunkier functions
python/mypy#6580

fields: Optional[Union[str, list[str]]],
expand: Optional[str],
json_result: Literal[True],
) -> Dict[str, Any]:
...

def search_issues(
self,
jql_str: str,
Expand Down