[Error] TypeError: sequence item 0: expected str instance, NoneType found
BaseMax opened this issue · comments
➜ howdoi --version
2.0.15
➜ howdoi I stupid -c
Further down the same page you linked to.... =)
"Paul Jungwirth wrote:
You have the numbers 123456789, in
that order. Between each number, you
must insert either nothing, a plus
sign, or a multiplication sign, so
that the resulting expression equals
2001. Write a program that prints all solutions. (There are two.)
I think you meant 2002, not 2001. :)
(Just correcting for anyone else like
me who obsessively tries to solve
little "practice" problems like this
one, and then hit Google when their
result doesn't match the stated
answer. ;) Damn, some of those Perl
examples are ugly.)"
➜ howdoi I stupid
Further down the same page you linked to.... =)
"Paul Jungwirth wrote:
You have the numbers 123456789, in
that order. Between each number, you
must insert either nothing, a plus
sign, or a multiplication sign, so
that the resulting expression equals
2001. Write a program that prints all solutions. (There are two.)
I think you meant 2002, not 2001. :)
(Just correcting for anyone else like
me who obsessively tries to solve
little "practice" problems like this
one, and then hit Google when their
result doesn't match the stated
answer. ;) Damn, some of those Perl
examples are ugly.)"
➜ howdoi I am stupid
Traceback (most recent call last):
File "/usr/bin/howdoi", line 12, in <module>
sys.exit(command_line_runner())
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 784, in command_line_runner
utf8_result = howdoi(args).encode('utf-8', 'ignore')
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 617, in howdoi
return _parse_cmd(args, res)
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 570, in _parse_cmd
answer = _format_answers(args, res)
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 490, in _format_answers
return build_splitter().join(formatted_answers)
TypeError: sequence item 0: expected str instance, NoneType found
➜ howdoi "I am stupid"
Traceback (most recent call last):
File "/usr/bin/howdoi", line 12, in <module>
sys.exit(command_line_runner())
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 784, in command_line_runner
utf8_result = howdoi(args).encode('utf-8', 'ignore')
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 602, in howdoi
return _parse_cmd(args, res)
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 570, in _parse_cmd
answer = _format_answers(args, res)
File "/usr/lib/python3.9/site-packages/howdoi/howdoi.py", line 490, in _format_answers
return build_splitter().join(formatted_answers)
TypeError: sequence item 0: expected str instance, NoneType found
That's interesting. I don't get that error when I try the search. Would you add a --explain
to see how the answer is being generated?
~ » howdoi I am stupid
idinizio
~ » howdoi "I am stupid"
idinizio
~ » howdoi -v
2.0.15
~ » howdoi I am stupid --explain -C
INFO: Version: 2.0.15
Cache cleared successfully
INFO: Fetching answers for query: I am stupid
INFO: Searching google with URL: https://www.google.com/search?q=site:stackoverflow.com%20I%20am%20stupid&hl=en
INFO: stackoverflow.com links found on google: 1
INFO: Answers requested: 1, Starting at position: 1
INFO: Total answers returned: 1
idinizio
$ docker run --rm python /bin/bash -c 'pip install --quiet howdoi && pip list && howdoi -xC edit photos macos'
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Package Version
------------------ ---------
appdirs 1.4.4
cachelib 0.3.0
certifi 2021.5.30
cffi 1.14.6
charset-normalizer 2.0.4
click 8.0.1
cssselect 1.1.0
Deprecated 1.2.13
howdoi 2.0.18
idna 3.2
keep 2.10.1
lxml 4.6.3
pip 21.2.4
pycparser 2.20
PyGithub 1.55
Pygments 2.10.0
PyJWT 2.1.0
PyNaCl 1.4.0
pyquery 1.4.3
requests 2.26.0
setuptools 57.5.0
six 1.16.0
terminaltables 3.1.0
urllib3 1.26.6
wheel 0.37.0
wrapt 1.12.1
INFO: Version: 2.0.18
INFO: Fetching answers for query: edit photos macos
INFO: Searching google with URL: https://www.google.com/search?q=site:stackoverflow.com%20edit%20photos%20macos&hl=en
INFO: stackoverflow.com links found on google: 1
INFO: Answers requested: 1, Starting at position: 1
�[92mCache cleared successfully�[0m
INFO: Fetching page: https://stackoverflow.com/questions/49623749/how-do-we-integrate-system-photo-editing-into-our-macos-apps
INFO: No code sample found, returning entire answer
INFO: Total answers returned: 1
Traceback (most recent call last):
File "/usr/local/bin/howdoi", line 8, in <module>
sys.exit(command_line_runner())
File "/usr/local/lib/python3.9/site-packages/howdoi/howdoi.py", line 810, in command_line_runner
utf8_result = howdoi(args).encode('utf-8', 'ignore')
File "/usr/local/lib/python3.9/site-packages/howdoi/howdoi.py", line 647, in howdoi
return _parse_cmd(args, res)
File "/usr/local/lib/python3.9/site-packages/howdoi/howdoi.py", line 585, in _parse_cmd
answer = _format_answers(args, res)
File "/usr/local/lib/python3.9/site-packages/howdoi/howdoi.py", line 505, in _format_answers
return build_splitter().join(formatted_answers)
TypeError: sequence item 0: expected str instance, NoneType found
Looks like this is happening because we're returning a question with no answer
I think this may fix your issue. Would you mind giving it a try?
Fixed in 2.0.19