Skip to content

Commit

Permalink
ImportError -> ModuleNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Nov 14, 2024
1 parent 38806e2 commit ccaf158
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Allow this file to be used standalone if desired, albeit without JSON serialization
try:
from . import serializer
except ImportError:
except ModuleNotFoundError:
serializer = None

from collections import defaultdict, namedtuple, OrderedDict
Expand Down Expand Up @@ -67,7 +67,7 @@
try:
from .ipython import ParamPager, ipython_async_executor as async_executor
param_pager = ParamPager(metaclass=True) # Generates param description
except ImportError:
except ModuleNotFoundError:
from ._utils import async_executor
else:
from ._utils import async_executor
Expand Down
2 changes: 1 addition & 1 deletion param/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def get_setupcfg_version():
"""
try:
import configparser
except ImportError:
except ModuleNotFoundError:
import ConfigParser as configparser # python2 (also prevents dict-like access)
import re
cfg = "setup.cfg"
Expand Down
4 changes: 2 additions & 2 deletions tests/testcomparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None
try:
import pandas as pd
except ImportError:
except ModuleNotFoundError:
pd = None

_now = datetime.datetime.now()
Expand Down
2 changes: 1 addition & 1 deletion tests/testdateparam.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None

from .utils import check_defaults
Expand Down
2 changes: 1 addition & 1 deletion tests/testdaterangeparam.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None

# Assuming tests of range parameter cover most of what's needed to
Expand Down
4 changes: 2 additions & 2 deletions tests/testdefaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

try:
import numpy # noqa
except ImportError:
except ModuleNotFoundError:
skip.append('Array')
try:
import pandas # noqa
except ImportError:
except ModuleNotFoundError:
skip.append('DataFrame')
skip.append('Series')

Expand Down
16 changes: 8 additions & 8 deletions tests/testfiledeserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
pd_ver = pd.__version__.split('.')
df = pd.DataFrame({'A':[1,2,3], 'B':[1.1,2.2,3.3]})
modern_pd = pd if (int(pd_ver[0]) >= 1 and int(pd_ver[1]) >= 2) else None
except ImportError:
except ModuleNotFoundError:
pd = df1 = df2 = modern_pd = None

# The writer could be xlsxwriter, but the sufficient condition is the presence of
# openpyxl
try:
import openpyxl as xlsxm
except ImportError:
except ModuleNotFoundError:
xlsxm = None

try:
import odf as ods
except ImportError:
except ModuleNotFoundError:
ods = None

# prior to pandas version 1.2, xlrd was always the default excel reader (though it
Expand All @@ -42,27 +42,27 @@
import xlrd as xls
if int(xls.__version__.split('.')[0]) > 2:
raise Exception()
except ImportError:
except ModuleNotFoundError:
if modern_pd is None:
xlsxm = None

try:
import pyarrow.feather as feather
except ImportError:
except ModuleNotFoundError:
feather = None

try:
import fastparquet as parquet
except ImportError:
except ModuleNotFoundError:
parquet = None
try:
import pyarrow as parquet
except ImportError:
except ModuleNotFoundError:
pass

try:
import tables as hdf5
except ImportError:
except ModuleNotFoundError:
hdf5 = None

np_skip = skipIf(np is None, "NumPy is not available")
Expand Down
2 changes: 1 addition & 1 deletion tests/testipythonmagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

try:
import IPython # noqa
except ImportError:
except ModuleNotFoundError:
import os
if os.getenv('PARAM_TEST_IPYTHON','0') == '1':
raise ImportError("PARAM_TEST_IPYTHON=1 but ipython not available.")
Expand Down
6 changes: 3 additions & 3 deletions tests/testjsonserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

try:
from jsonschema import validate, ValidationError
except ImportError:
except ModuleNotFoundError:
import os
if os.getenv('PARAM_TEST_JSONSCHEMA','0') == '1':
raise ImportError("PARAM_TEST_JSONSCHEMA=1 but jsonschema not available.")
Expand All @@ -25,7 +25,7 @@
ndarray = np.array([[1,2,3],[4,5,6]])
npdt1 = np.datetime64(now)
npdt2 = np.datetime64(after_now)
except ImportError:
except ModuleNotFoundError:
np, ndarray, npdt1, npdt2 = None, None, None, None

np_skip = skipIf(np is None, "NumPy is not available")
Expand All @@ -36,7 +36,7 @@
df2 = pd.DataFrame({'A':[1.1,2.2,3.3], 'B':[1.1,2.2,3.3]})
pdts1 = pd.Timestamp(now)
pdts2 = pd.Timestamp(after_now)
except ImportError:
except ModuleNotFoundError:
pd, df1, df2, pdts1, pdts2 = None, None, None, None, None

pd_skip = skipIf(pd is None, "pandas is not available")
Expand Down
2 changes: 1 addition & 1 deletion tests/testnumberparameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None

class TestNumberParameters(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/testnumpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
try:
import numpy
import numpy.testing
except ImportError:
except ModuleNotFoundError:
if os.getenv('PARAM_TEST_NUMPY','0') == '1':
raise ImportError("PARAM_TEST_NUMPY=1 but numpy not available.")
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/testpandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

try:
import pandas
except ImportError:
except ModuleNotFoundError:
if os.getenv('PARAM_TEST_PANDAS','0') == '1':
raise ImportError("PARAM_TEST_PANDAS=1 but pandas not available.")
else:
Expand Down
6 changes: 3 additions & 3 deletions tests/testpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

try:
import cloudpickle
except ImportError:
except ModuleNotFoundError:
cloudpickle = None
try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None
try:
import pandas as pd
except ImportError:
except ModuleNotFoundError:
pd = None


Expand Down
4 changes: 2 additions & 2 deletions tests/testreactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
if os.getenv('PARAM_TEST_NUMPY','0') == '1':
raise ImportError("PARAM_TEST_NUMPY=1 but numpy not available.")
else:
raise unittest.SkipTest("numpy not available")

try:
import pandas as pd
except ImportError:
except ModuleNotFoundError:
if os.getenv('PARAM_TEST_PANDAS','0') == '1':
raise ImportError("PARAM_TEST_PANDAS=1 but pandas not available.")
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/testtimedependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

try:
import gmpy
except ImportError:
except ModuleNotFoundError:
import os
if os.getenv('PARAM_TEST_GMPY','0') == '1':
raise ImportError("PARAM_TEST_GMPY=1 but gmpy not available.")
Expand Down
2 changes: 1 addition & 1 deletion tests/testtupleparam.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None


Expand Down
4 changes: 2 additions & 2 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

try:
import numpy as np
except ImportError:
except ModuleNotFoundError:
np = None

try:
import pandas as pd
except ImportError:
except ModuleNotFoundError:
pd = None

now = dt.datetime.now()
Expand Down

0 comments on commit ccaf158

Please sign in to comment.