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

Add generated types #6

Merged
merged 18 commits into from
Sep 6, 2019
Merged

Conversation

nathanmsmith
Copy link
Contributor

@nathanmsmith nathanmsmith commented Sep 4, 2019

Adds generated types to the python bot.

I tried to add type hinting where it makes sense, but we won't get full type coverage at least until lidatong/dataclasses-json#23 is resolved. We still get the big win of having all dataclasses defined.

All examples and tests should work. A few dataclass field names were changed in the process.

Note that chat methods now take dataclasses and input and return dataclasses as output, as opposed to dicts as we did previously.

return json.loads(response)
parsed_response = json.loads(response)
if "error" in parsed_response:
raise Exception(parsed_response["error"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pass errors from the service through

@nathanmsmith nathanmsmith marked this pull request as ready for review September 6, 2019 17:29
@@ -30,13 +31,17 @@ class Handler:
async def __call__(self, bot, event):
if event.type != EventType.WALLET:
return
if event.notification.statusDescription != PaymentStatusStr.COMPLETED:
print(event.notification)
Copy link
Collaborator

Choose a reason for hiding this comment

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

?


logging.basicConfig(level=logging.DEBUG)


async def handler(bot, event):
if event.msg.content.type != ContentType.TEXT:
if event.msg.content.type_name != chat1.MessageTypeStrings.TEXT.value:
Copy link
Collaborator

Choose a reason for hiding this comment

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

chat1.MessageTypeStrings.TEXT.value <-- this is pretty unfortunate for something as common as this '__'

return
channel = event.msg.channel
msg_id = event.msg.id
await bot.chat.react(channel.replyable_dict(), msg_id, ":clap:")
await bot.chat.react(channel, msg_id, ":clap:")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is nicer though :)


logging.basicConfig(level=logging.DEBUG)


class Handler:
async def __call__(self, bot, event):
if event.msg.content.type != ContentType.TEXT:
if event.msg.content.type_name != chat1.MessageTypeStrings.TEXT.value:
Copy link
Collaborator

Choose a reason for hiding this comment

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

i feel like no one is actually going to do this. they'll just write "text" here instead. 🙃

Copy link
Collaborator

@xgess xgess left a comment

Choose a reason for hiding this comment

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

14k lines changed. what could possibly go wrong?? :shipit:

@nathanmsmith nathanmsmith merged commit 774ae77 into master Sep 6, 2019
@nathanmsmith nathanmsmith deleted the nathan/PICNIC-269-generated-types branch September 6, 2019 19:38
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.

2 participants