gleitz / howdoi

instant coding answers via the command line
http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line
MIT License
10.56k stars 867 forks source link

Add query range check (#471) #474

Closed CaedenPH closed 1 year ago

CaedenPH commented 1 year ago

Description:

Pull Request type:

How to test:

>>> python -m howdoi a
ERROR: Please make a valid query

Please provide detailed instructions for testing your changes locally, including expected response/behavior.

def test_query_length(self):
        self.assertIn("Please make a valid query", howdoi.howdoi("a"))

Any one word query with less than 2 letters should error

Pull Request checklist:

image

CaedenPH commented 1 year ago

@gleitz Pinging for review

CaedenPH commented 1 year ago

@gleitz The first commit was a mistake :eyes: Apologies

gleitz commented 1 year ago

What do you think about the tradeoffs between putting the check inside the howdoi function, vs a check on the argparse library?

If someone really wanted to look up howdoi c (perhaps for c programming) should we allow that?

CaedenPH commented 1 year ago

What do you think about the tradeoffs between putting the check inside the howdoi function, vs a check on the argparse library?

If someone really wanted to look up howdoi c (perhaps for c programming) should we allow that?

What is the output of howdoi c? Does it actually provide a useful output?

gleitz commented 1 year ago

At the moment it's not very useful. It was more of a question of whether we want to put this range check at the command line level with argparse, and allowing any people who use howdoi as a library to continue to do so without limitations.

In practice it probably doesn't matter, just an interesting philosophical question of command line vs. library level range checks.

CaedenPH commented 1 year ago

At the moment it's not very useful. It was more of a question of whether we want to put this range check at the command line level with argparse, and allowing any people who use howdoi as a library to continue to do so without limitations.

In practice it probably doesn't matter, just an interesting philosophical question of command line vs. library level range checks.

Ah, I see what you mean. Now that you raise the point, I think command line would actually be better to allow for more library control