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

Passing an invalid flavor to read_html prints the wrong error message #23549

Closed
achabotl opened this issue Nov 7, 2018 · 1 comment

Comments

Projects
None yet
4 participants
@achabotl
Copy link

commented Nov 7, 2018

Code Sample, a copy-pastable example if possible

>>> import pandas as pd
>>> df_list = pd.read_html('https://google.com', flavor='unknown')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/achabot/envs/tmp-b79b7181308bb9c1/lib/python3.7/site-packages/pandas/io/html.py", line 987, in read_html
    displayed_only=displayed_only)
  File "/Users/achabot/envs/tmp-b79b7181308bb9c1/lib/python3.7/site-packages/pandas/io/html.py", line 787, in _parse
    flavor = _validate_flavor(flavor)
  File "/Users/achabot/envs/tmp-b79b7181308bb9c1/lib/python3.7/site-packages/pandas/io/html.py", line 782, in _validate_flavor
    valid=_print_as_set(valid_flavors)))
ValueError: {arg} is not a valid set of flavors, valid flavors are {arg}

Problem description

The error message should show the flavor selected and the valid choices. It's happenning on this line below, and it's a regression from previous versions, which used %-formatting and worked properly.

return '{{arg}}'.format(arg=', '.join(pprint_thing(el) for el in s))

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.0.final.0
python-bits: 64
OS: Darwin
OS-release: 18.2.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.5.0
Cython: None
numpy: 1.15.4
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@gfyoung

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

We actually have a test for this, but we don't check the error message. Oops.

gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 7, 2018

BUG: Fix error message for invalid HTML flavor
The flavors were not rendering properly in the
string formatting.

Closes pandas-devgh-23549.
Follow-up to pandas-devgh-17660.

@gfyoung gfyoung removed this from the Contributions Welcome milestone Nov 7, 2018

TomAugspurger added a commit that referenced this issue Nov 8, 2018

BUG: Fix error message for invalid HTML flavor (#23550)
The flavors were not rendering properly in the
string formatting.

Closes gh-23549.
Follow-up to gh-17660.

JustinZhengBC added a commit to JustinZhengBC/pandas that referenced this issue Nov 14, 2018

BUG: Fix error message for invalid HTML flavor (pandas-dev#23550)
The flavors were not rendering properly in the
string formatting.

Closes pandas-devgh-23549.
Follow-up to pandas-devgh-17660.

brute4s99 added a commit to brute4s99/pandas that referenced this issue Nov 19, 2018

BUG: Fix error message for invalid HTML flavor (pandas-dev#23550)
The flavors were not rendering properly in the
string formatting.

Closes pandas-devgh-23549.
Follow-up to pandas-devgh-17660.

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

BUG: Fix error message for invalid HTML flavor (pandas-dev#23550)
The flavors were not rendering properly in the
string formatting.

Closes pandas-devgh-23549.
Follow-up to pandas-devgh-17660.

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

BUG: Fix error message for invalid HTML flavor (pandas-dev#23550)
The flavors were not rendering properly in the
string formatting.

Closes pandas-devgh-23549.
Follow-up to pandas-devgh-17660.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.