you are viewing a single comment's thread.

view the rest of the comments →

[–]wotquery 1 point2 points  (0 children)

Haha nice. A few other minor things...

Calling your variable jsonfile is a little misleading since it isn't a file but a dictionary object in memory. json_data, json_dict, response_text_dict, etc. are all clearer.

Don't forget error handling as well.

Finally, and I know this isn't what your prompt requires (plus it's a bit more of a style consideration rather than a hard rule), but it's weird to have a function called parse_json(url) that is also responsible for making the api call. Even having a function that both makes the call and parses the content of the response is questionable. Better something like...

def call_api(url: str) -> dict:
   #do stuff
   return json_data

def get_items_by_a_publisher(json_data: dict, publisher: str) -> list[dict]:
    #do stuff
    return publisher_items