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

added phone field in print_user function #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

waclawthedev
Copy link
Owner

No description provided.

with open(filename, "w") as file:
json.dump(user_data, file, indent=4)


def read_user_from_file(filename):
def read_user_from_file(filename: str) -> dict:
with open(filename, "r") as file:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Add exception handling for case of non-existing file

name = user["results"][0]["name"]
print(f"Name: {name['title']} {name['first']} {name['last']}")
email = user["results"][0]["email"]
print(f"Email: {email}")
phone = user["results"][0]["phone"]
Copy link
Owner Author

Choose a reason for hiding this comment

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

Avoid directly getting elements and fields from dictionary. Make it safe here and everywhere in this function. Refactor this function.

@@ -2,26 +2,28 @@
import requests


def fetch_random_user():
def fetch_random_user() -> dict:
response = requests.get("https://randomuser.me/api/")
Copy link
Owner Author

Choose a reason for hiding this comment

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

measure and print how much time get request took

@@ -1,2 +1,2 @@
# demo_repo_for_gptmypr
Sample project to practice using gptmypr tool
Sample project to practice using gptmypr tool (https://github.com/waclawthedev/GPTmyPR)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Tell more about GPT (2 sentences)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant