Unnecessary API requests
From my reading of the code, it seems that posting a Reaction to an Issue Comment results in two unnecessary get requests. I haven't been able to watch the actual network traffic to verify this though.
In the following example it looks like the two get requests will be mabe but are not needed.
# No API call because of lazy=True
repo = github.get_repo(repo_name, lazy=True)
# GET: /repos/{owner}/{repo}/issues/{id}
issue = repo.get_issue(number=issue_id)
# GET: /repos/{owner}/{repo}/issues/comments/{id}
comment = issue.get_comment(comment_id)
# POST: /repos/{owner}/{repo}/issues/comments/{id}/reactions
reaction = comment.create_reaction(reaction_type)
Is this right?
Can we add lazy to all get methods?
Can we add lazy to all get methods?
A possible alternative would be to provide easier ways to create child objects directly e.g. here the entire traversal is useless what you really want is to create an IssueComment directly from the bare minimum metadata because you're assuming / asserting the existence of the issue and comment id (because you got the information from somewhere else e.g. a webhook).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I like @xmo-odoo's idea too!
If I can get feedback from the maintainers on this aproach and an indication that the project is still active. If I submit a PR for this, is it likely to get reviewed and accepted?
I'd go for adding lazy to get_issue and get_comment. Because that way, many more methods on Issue and IssueComment can be used without firing API requests.
It's worth creating a PR.