diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 681e3dc1..783bd065 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,8 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: + - id: no-commit-to-branch + args: ['--branch', 'master'] - id: check-yaml - id: debug-statements - id: end-of-file-fixer diff --git a/pyscal/factory.py b/pyscal/factory.py index 2542febd..f4bffafd 100644 --- a/pyscal/factory.py +++ b/pyscal/factory.py @@ -1068,13 +1068,15 @@ def infer_tabular_file_format(filename): try: pd.read_excel(filename, engine="openpyxl") return "xlsx" - except openpyxl.utils.exceptions.InvalidFileException: - # We get here for both CSV and XLS files. + except (ValueError, OSError, openpyxl.utils.exceptions.InvalidFileException): + # < Pandas 1.2, we get InvalidFileException from openpyxl + # >= Pandas 1.2.0: CSV gives ValueError, + # XLS gives OSError pass try: pd.read_excel(filename, engine="xlrd") return "xls" - except xlrd.biffh.XLRDError: + except (ValueError, xlrd.biffh.XLRDError): # We get here for both CSV and XLSX files. pass try: