Skip to content

Commit 495a0c1

Browse files
jbrockmendeljreback
authored andcommitted
[BLD] [CLN] Close assorted issues - bare exceptions, unused func (#22030)
1 parent a1a2f66 commit 495a0c1

File tree

13 files changed

+17
-65
lines changed

13 files changed

+17
-65
lines changed

pandas/_libs/skiplist.pxd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from cython cimport Py_ssize_t
55

6-
from numpy cimport double_t
7-
86

97
cdef extern from "src/skiplist.h":
108
ctypedef struct node_t:
@@ -33,7 +31,7 @@ cdef extern from "src/skiplist.h":
3331
# Node itself not intended to be exposed.
3432
cdef class Node:
3533
cdef public:
36-
double_t value
34+
double value
3735
list next
3836
list width
3937

pandas/_libs/skiplist.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
from libc.math cimport log
1010

1111
import numpy as np
12-
cimport numpy as cnp
13-
from numpy cimport double_t
14-
cnp.import_array()
1512

1613

1714
# MSVC does not have log2!
@@ -26,11 +23,11 @@ from random import random
2623

2724
cdef class Node:
2825
# cdef public:
29-
# double_t value
26+
# double value
3027
# list next
3128
# list width
3229

33-
def __init__(self, double_t value, list next, list width):
30+
def __init__(self, double value, list next, list width):
3431
self.value = value
3532
self.next = next
3633
self.width = width

pandas/_libs/src/compat_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The full license is in the LICENSE file, distributed with this software.
1111
#define PANDAS__LIBS_SRC_COMPAT_HELPER_H_
1212

1313
#include "Python.h"
14-
#include "numpy_helper.h"
14+
#include "helper.h"
1515

1616
/*
1717
PySlice_GetIndicesEx changes signature in PY3

pandas/core/tools/timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _validate_timedelta_unit(arg):
131131
""" provide validation / translation for timedelta short units """
132132
try:
133133
return _unit_map[arg]
134-
except:
134+
except (KeyError, TypeError):
135135
if arg is None:
136136
return 'ns'
137137
raise ValueError("invalid timedelta unit {arg} provided"

pandas/io/s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
try:
44
import s3fs
55
from botocore.exceptions import NoCredentialsError
6-
except:
6+
except ImportError:
77
raise ImportError("The s3fs library is required to handle s3 files")
88

99
if compat.PY3:

pandas/tests/frame/test_missing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import scipy
2828
_is_scipy_ge_0190 = (LooseVersion(scipy.__version__) >=
2929
LooseVersion('0.19.0'))
30-
except:
30+
except ImportError:
3131
_is_scipy_ge_0190 = False
3232

3333

pandas/tests/io/generate_legacy_storage_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def write_legacy_pickles(output_dir):
303303
# make sure we are < 0.13 compat (in py3)
304304
try:
305305
from pandas.compat import zip, cPickle as pickle # noqa
306-
except:
306+
except ImportError:
307307
import pickle
308308

309309
version = pandas.__version__

pandas/tests/io/test_pickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def c_unpickler(path):
218218
with open(path, 'rb') as fh:
219219
fh.seek(0)
220220
return c_pickle.load(fh)
221-
except:
221+
except ImportError:
222222
c_pickler = None
223223
c_unpickler = None
224224

pandas/tests/io/test_sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def _transaction_test(self):
468468
with self.pandasSQL.run_transaction() as trans:
469469
trans.execute(ins_sql)
470470
raise Exception('error')
471-
except:
471+
except Exception:
472472
# ignore raised exception
473473
pass
474474
res = self.pandasSQL.read_query('SELECT * FROM test_trans')

pandas/tests/series/test_missing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import scipy
2828
_is_scipy_ge_0190 = (LooseVersion(scipy.__version__) >=
2929
LooseVersion('0.19.0'))
30-
except:
30+
except ImportError:
3131
_is_scipy_ge_0190 = False
3232

3333

0 commit comments

Comments
 (0)