Skip to content

Commit ab8105f

Browse files
committed
Build out more of our type-stubs
1 parent da2989c commit ab8105f

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

github3/decorators.pyi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing import (
2+
Any,
3+
)
4+
5+
import io
6+
7+
import requests
8+
9+
10+
class RequestsStringIO(io.BytesIO):
11+
def read(self, n: int=-1, *args, **kwargs) -> bytes: # type: ignore
12+
...
13+
14+
15+
# These decorators are broken until there's a solution to
16+
# https://github.com/python/typing/issues/193
17+
# https://github.com/python/mypy/issues/1317
18+
def requires_auth(func: Any) -> Any:
19+
...
20+
21+
22+
def requires_basic_auth(func: Any) -> Any:
23+
...
24+
25+
26+
def requires_app_credentials(func: Any) -> Any:
27+
...
28+
29+
30+
def generate_fake_error_message(
31+
msg: str,
32+
status_code: int=401,
33+
encoding: str='utf-8',
34+
) -> requests.models.Response:
35+
...

github3/gists/gist.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class _Gist:
1+
from .. import models
2+
3+
4+
class _Gist(models.GitHubCore):
25
...
36

47

github3/github.pyi

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from typing import (
99
)
1010

1111
from . import auths
12+
from . import decorators
1213
from . import events
1314
from . import models
1415
from . import orgs
@@ -30,6 +31,7 @@ class GitHub(models.GitHubCore):
3031
) -> None:
3132
...
3233

34+
@decorators.requires_auth
3335
def add_email_addresses(
3436
self: T,
3537
addresses: List[str]=[],
@@ -70,6 +72,7 @@ class GitHub(models.GitHubCore):
7072
) -> structs.GitHubIterator[users.ShortUser]:
7173
...
7274

75+
@decorators.requires_basic_auth
7376
def authorization(
7477
self: T,
7578
id_num: Union[int, str],
@@ -109,6 +112,7 @@ class GitHub(models.GitHubCore):
109112
) -> gist.Gist:
110113
...
111114

115+
@decorators.requires_auth
112116
def create_issue(
113117
self: T,
114118
owner: str,
@@ -122,6 +126,7 @@ class GitHub(models.GitHubCore):
122126
) -> issue.ShortIssue:
123127
...
124128

129+
@decorators.requires_auth
125130
def create_key(
126131
self: T,
127132
title: str,
@@ -130,6 +135,7 @@ class GitHub(models.GitHubCore):
130135
) -> users.Key:
131136
...
132137

138+
@decorators.requires_auth
133139
def create_repository(
134140
self: T,
135141
name: str,
@@ -143,12 +149,14 @@ class GitHub(models.GitHubCore):
143149
) -> repo.Repository:
144150
...
145151

152+
@decorators.requires_auth
146153
def delete_email_addresses(
147154
self: T,
148155
addresses: List[str],
149156
) -> bool:
150157
...
151158

159+
@decorators.requires_auth
152160
def emails(
153161
self: T,
154162
number: int=-1,
@@ -162,6 +170,7 @@ class GitHub(models.GitHubCore):
162170
def feeds(self: T) -> Dict[str, Any]:
163171
...
164172

173+
@decorators.requires_auth
165174
def follow(
166175
self: T,
167176
username: str
@@ -175,3 +184,49 @@ class GitHub(models.GitHubCore):
175184
etag: Optional[str]=None,
176185
) -> structs.GitHubIterator[users.ShortUser]:
177186
...
187+
188+
@decorators.requires_auth
189+
def followers(
190+
self: T,
191+
number: int=-1,
192+
etag: Optional[str]=None,
193+
) -> structs.GitHubIterator[users.ShortUser]:
194+
...
195+
196+
def followers_of(
197+
self: T,
198+
username: str,
199+
number: int=-1,
200+
etag: Optional[str]=None,
201+
) -> structs.GitHubIterator[users.ShortUser]:
202+
...
203+
204+
@decorators.requires_auth
205+
def following(
206+
self: T,
207+
number: int=-1,
208+
etag: Optional[str]=None,
209+
) -> structs.GitHubIterator[users.ShortUser]:
210+
...
211+
212+
def gist(
213+
self: T,
214+
id_num: int,
215+
) -> gist.Gist:
216+
...
217+
218+
@decorators.requires_auth
219+
def gists(
220+
self: T,
221+
number: int=-1,
222+
etag: Optional[str]=None,
223+
) -> structs.GitHubIterator[gist.ShortGist]:
224+
...
225+
226+
def gists_by(
227+
self: T,
228+
username: str,
229+
number: int=-1,
230+
etag: Optional[str]=None,
231+
) -> structs.GitHubIterator[gist.ShortGist]:
232+
...

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy