Skip to content
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

Use property decorator to improve typing compatibility #1925

Merged
merged 1 commit into from Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions github/MainClass.py
Expand Up @@ -142,31 +142,29 @@ def __init__(
pool_size,
)

def __get_FIX_REPO_GET_GIT_REF(self):
@property
def FIX_REPO_GET_GIT_REF(self):
"""
:type: bool
"""
return self.__requester.FIX_REPO_GET_GIT_REF

def __set_FIX_REPO_GET_GIT_REF(self, value):
@FIX_REPO_GET_GIT_REF.setter
def FIX_REPO_GET_GIT_REF(self, value):
self.__requester.FIX_REPO_GET_GIT_REF = value

FIX_REPO_GET_GIT_REF = property(
__get_FIX_REPO_GET_GIT_REF, __set_FIX_REPO_GET_GIT_REF
)

def __get_per_page(self):
# v2: Remove this property? Why should it be necessary to read/modify it after construction
@property
def per_page(self):
"""
:type: int
"""
return self.__requester.per_page

def __set_per_page(self, value):
@per_page.setter
def per_page(self, value):
self.__requester.per_page = value

# v2: Remove this property? Why should it be necessary to read/modify it after construction
per_page = property(__get_per_page, __set_per_page)

# v2: Provide a unified way to access values of headers of last response
# v2: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.)
# v2: Return an instance of a class: using a tuple did not allow to add a field "resettime"
Expand Down
12 changes: 8 additions & 4 deletions github/MainClass.pyi
Expand Up @@ -41,10 +41,14 @@ class Github:
verify: bool = ...,
retry: Any = ...,
) -> None: ...
def __get_FIX_REPO_GET_GIT_REF(self) -> bool: ...
def __set_FIX_REPO_GET_GIT_REF(self, value: bool) -> None: ...
def __get_per_page(self) -> int: ...
def __set_per_page(self, value: int) -> None: ...
@property
def FIX_REPO_GET_GIT_REF(self) -> bool: ...
@FIX_REPO_GET_GIT_REF.setter
def FIX_REPO_GET_GIT_REF(self, value: bool) -> None: ...
@property
def per_page(self) -> int: ...
@per_page.setter
def per_page(self, value: int) -> None: ...
def create_from_raw_data(
self,
klass: Type[TGithubObject],
Expand Down