-
Notifications
You must be signed in to change notification settings - Fork 1
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
#6: add indexing to BodyOfTheLastResponse. #7
Conversation
@@ -23,11 +23,11 @@ def generate_send_method_class(method: str) -> Type[APIMethodAction]: | |||
""" | |||
|
|||
class SendMETHODRequest: | |||
"Will be programmatically replaced." | |||
"""Will be programmatically replaced.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah also i had this fix here for months. Haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure when we add ruff to the project, all these would be updated anyway.
@@ -53,6 +52,32 @@ def test_ask_for_body_of_the_last_response(self, APITester): | |||
|
|||
assert BodyOfTheLastResponse().answered_by(APITester) == test_json | |||
|
|||
def test_stores_index_path(self): | |||
botlr = BodyOfTheLastResponse()["shuffled"]["off"][10]["mortal"]["coils"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a slice here.
Looks good! Only have one last suggestion: add a slice example to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clever sir.
This PR adds
__getitem__
handling forBodyOfTheLastResponse
, which does two things:body_parts
(sorry i couldn't help myself).self
.This means further indexing will be kept track of in the
body_parts
list. As the question is answered,BodyOfTheLastResponse
checks if it has anybody_parts
, and will travel down the list for the user while answering the Question.One thing for discussion—should a
KeyError
orIndexError
just be let to bubble up, or should we catch that and tell the user what went wrong?