Skip to content

Commit a7b4311

Browse files
ocivocclausspoyea
authored
fix fetch_github_info __main__ bug (TheAlgorithms#2080)
* fix fetch_github_info __main__ bug * Algorithms should not print * Update fetch_github_info.py * Update fetch_github_info.py Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: John Law <[email protected]>
1 parent 657d461 commit a7b4311

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

web_programming/fetch_github_info.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
# Created by sarathkaul on 14/11/19
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Created by sarathkaul on 14/11/19
5+
6+
Basic authentication using an API password is deprecated and will soon no longer work.
7+
Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth
8+
for more information around suggested workarounds and removal dates.
9+
"""
10+
211

312
import requests
413

514
_GITHUB_API = "https://api.github.com/user"
615

716

8-
def fetch_github_info(auth_user: str, auth_pass: str) -> None:
9-
# fetching github info using requests
10-
info = requests.get(_GITHUB_API, auth=(auth_user, auth_pass))
11-
12-
for a_info, a_detail in info.json().items():
13-
print(f"{a_info}: {a_detail}")
17+
def fetch_github_info(auth_user: str, auth_pass: str) -> dict:
18+
"""
19+
Fetch GitHub info of a user using the requests module
20+
"""
21+
return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json()
1422

1523

16-
if __name__ == "main":
17-
fetch_github_info("<USER NAME>", "<PASSWORD>")
24+
if __name__ == "__main__":
25+
for key, value in fetch_github_info("<USER NAME>", "<PASSWORD>").items():
26+
print(f"{key}: {value}")

0 commit comments

Comments
 (0)