Skip to content

Commit 2e6ee26

Browse files
authored
Merge pull request statsmodels#5203 from jbrockmendel/again
BUG: webdoc: raise instead of return ValueError
2 parents ee00540 + de5b9ff commit 2e6ee26

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lint.sh

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ if [ "$LINT" == true ]; then
3030
statsmodels/duration/__init__.py \
3131
statsmodels/regression/recursive_ls.py \
3232
statsmodels/tools/linalg.py \
33+
statsmodels/tools/web.py \
3334
statsmodels/tools/tests/test_linalg.py \
3435
statsmodels/tools/decorators.py \
3536
statsmodels/tools/tests/test_decorators.py \

statsmodels/tools/web.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"""
55
import webbrowser
66

7-
from statsmodels.compat.python import urlencode
7+
from statsmodels.compat.python import urlencode, string_types
88
from statsmodels import __version__
99

1010
BASE_URL = 'https://www.statsmodels.org/'
1111

1212

1313
def _generate_url(arg, stable):
1414
"""
15-
Parse inputs and return a correctly formatted URL or an error if the input
16-
is not understandable
15+
Parse inputs and return a correctly formatted URL or raises ValueError
16+
if the input is not understandable
1717
"""
1818
url = BASE_URL
1919
if stable:
@@ -23,7 +23,7 @@ def _generate_url(arg, stable):
2323

2424
if arg is None:
2525
return url
26-
elif type(arg) is str:
26+
elif isinstance(arg, string_types):
2727
url += 'search.html?'
2828
url += urlencode({'q': arg})
2929
url += '&check_keywords=yes&area=default'
@@ -33,11 +33,11 @@ def _generate_url(arg, stable):
3333
func_name = func.__name__
3434
func_module = func.__module__
3535
if not func_module.startswith('statsmodels.'):
36-
return ValueError('Function must be from statsmodels')
36+
raise ValueError('Function must be from statsmodels')
3737
url += 'generated/'
3838
url += func_module + '.' + func_name + '.html'
39-
except:
40-
return ValueError('Input not understood')
39+
except AttributeError:
40+
raise ValueError('Input not understood')
4141
return url
4242

4343

@@ -71,7 +71,5 @@ def webdoc(arg=None, stable=None):
7171
"""
7272
stable = __version__ if 'dev' not in __version__ else stable
7373
url_or_error = _generate_url(arg, stable)
74-
if isinstance(url_or_error, ValueError):
75-
raise url_or_error
7674
webbrowser.open(url_or_error)
7775
return None

0 commit comments

Comments
 (0)