Skip to content

Minor code cleaning, formatted error messages #201

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

williamsonz
Copy link

No description provided.

Copy link
Owner

@swapagarwal swapagarwal left a comment

Choose a reason for hiding this comment

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

I was expecting a PR to modularize the error messages. 😅

@williamsonz
Copy link
Author

williamsonz commented Jun 15, 2017 via email

Copy link
Owner

@swapagarwal swapagarwal left a comment

Choose a reason for hiding this comment

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

I like the direction this is going. 😄
You've picked up a nice refactoring opportunity!

@@ -0,0 +1,55 @@

Copy link
Owner

Choose a reason for hiding this comment

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

This isn't a module. It's more of a helper class. Can be moved to modules/examples.py
Keep the base error in the module itself for now, and extract just the list of examples out. This should be used both for the error messages in src files, as well as in tests.

Copy link
Author

Choose a reason for hiding this comment

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

Unsure, so asking for clarification:
Split into two files, one for error messages (error_msg.py) and one for examples (examples.py)?
I understand storing them a directory above, to use for both tests and src files.

Copy link
Owner

Choose a reason for hiding this comment

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

Let's make only one file now: examples.py. (error_msg.py can be created later if required; let the error messages be in the corresponding module itself, like it is now. Will visit it later)
examples file would have a list of sample queries for each of the modules, which will be used in both src and tests.

help += '\n\nI\'m always learning, so do come back and say hi from time to time!'
help += '\nHave a nice day. :)'
helper = helper.replace('there', entities['sender']['first_name'])
helper += """
Copy link
Owner

Choose a reason for hiding this comment

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

Reset this file and others which are related to triple-quoting the strings. They can be picked up in a separate PR.

Copy link
Author

Choose a reason for hiding this comment

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

Covered in the initial pull-request; I will include it with the next one,

Copy link
Owner

Choose a reason for hiding this comment

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

Remove these changes for now. Only keep the examples refactoring in this PR.

@swapagarwal
Copy link
Owner

Also, rebase your work on the current master to remove conflicts.

@@ -0,0 +1,49 @@
EXAMPLE_ANIME = """
- Death Note anime,

Choose a reason for hiding this comment

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

W291 trailing whitespace

- HKD to USD
- USD to EUR rate
- how much is 100 USD to INR"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- define comfort
- cloud definition
- what does an accolade mean?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- paradise lyrics
- lyrics of the song hall of fame
- What are the lyrics to see you again?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- batman movie
- iron man 2 movie plot
- What is the rating of happiness movie?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- time in new york
- india time
- time at paris"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- sia videos
- videos by eminem
- video coldplay"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- tell me the weather in London
- weather Delhi
- What's the weather in Texas?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

EXAMPLE_WIKI = """
- wikipedia barack
- html wiki
- who is sachin tendulkar"""

Choose a reason for hiding this comment

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

W292 no newline at end of file

LOCATION_ERROR = "I couldn't get the {} at the location you specified." + BASE_ERROR

EXAMPLE_ANIME = """
- Death Note anime,

Choose a reason for hiding this comment

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

W291 trailing whitespace

- HKD to USD
- USD to EUR rate
- how much is 100 USD to INR"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- define comfort
- cloud definition
- what does an accolade mean?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- paradise lyrics
- lyrics of the song hall of fame
- What are the lyrics to see you again?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- batman movie
- iron man 2 movie plot
- What is the rating of happiness movie?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- time in new york
- india time
- time at paris"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- sia videos
- videos by eminem
- video coldplay"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- tell me the weather in London
- weather Delhi
- What's the weather in Texas?"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

EXAMPLE_WIKI = """
- wikipedia barack
- html wiki
- who is sachin tendulkar"""

Choose a reason for hiding this comment

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

W292 no newline at end of file

- show a random xkcd comic
- latest news
- paradise lyrics

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

- hymn for the weekend song
- linkin park songs
- play hotel california"""

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

request += '\n - Report a bug (I couldn\'t handle the query and/or gave unexpected results), by including your search query and the expected result.'
request = """Kindly use the following buttons to:
- Request a new feature, by including some sample queries and their expected results.
- Report a bug (I couldn't handle the query and/or gave unexpected results), by including your search query and the expected result."""

Choose a reason for hiding this comment

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

E501 line too long (139 > 120 characters)

error_message += '\n - time in new york'
error_message += '\n - india time'
error_message += '\n - time at paris'
error_message = LOCATION_ERROR.format('time') + EXAMPLE_TIME

Choose a reason for hiding this comment

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

F821 undefined name 'LOCATION_ERROR'
F821 undefined name 'EXAMPLE_TIME'

error_message += '\n - sia videos'
error_message += '\n - videos by eminem'
error_message += '\n - video coldplay'
error_message = QUERY_ERROR.format('videos') + EXAMPLE_VIDEOS

Choose a reason for hiding this comment

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

F405 'EXAMPLE_VIDEOS' may be undefined, or defined from star imports: templates.generic

@horrormyth
Copy link

@williamsonz Could we fix these, please.

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

Successfully merging this pull request may close these issues.

4 participants