Skip to content

Commit 8e17005

Browse files
committed
Improve typing experience of Jira instanziation
1 parent c69eb92 commit 8e17005

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

atlassian/jira.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from typing_extensions import Literal # Python <=3.7
1616
from .errors import ApiNotFoundError, ApiPermissionError
1717
from .rest_client import AtlassianRestAPI
18-
from .typehints import T_id, T_resp_json
18+
from .typehints import T_id, T_resp_json, copy_type
1919

2020
log = logging.getLogger(__name__)
2121

@@ -26,6 +26,7 @@ class Jira(AtlassianRestAPI):
2626
Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2
2727
"""
2828

29+
@copy_type(AtlassianRestAPI.__init__)
2930
def __init__(self, url: str, *args: Any, **kwargs: Any):
3031
if "api_version" not in kwargs:
3132
kwargs["api_version"] = "2"

atlassian/typehints.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
from typing import Union
1+
from typing import Union, TypeVar, Callable, Any
22

33
from typing_extensions import TypeAlias
44

55
T_id: TypeAlias = Union[str, int]
66
_Data: TypeAlias = Union[dict, str]
77
T_resp_json: TypeAlias = Union[dict, None]
8+
9+
_T = TypeVar("T")
10+
11+
def copy_type(_:_T) -> Callable[[Any], _T]:
12+
"""Decorator to inherit typing from parent."""
13+
return lambda x: x

0 commit comments

Comments
 (0)