API: many custom errors / warnings are not exposed in pandas.errors
See original GitHub issueFrom https://github.com/pandas-dev/pandas/issues/27553 and https://github.com/pandas-dev/pandas/issues/27522, I quickly looked at how consistent we are with defining errors and warnings in pandas.errors
.
So we have a pandas.errors
module which is meant to publicly expose our custom exceptions and warnings.
Some are defined there such as PerformanceWarning, UnsortedIndexError, ParserError, … (https://github.com/pandas-dev/pandas/blob/bb6135880e5e453d7701764b9f2e4ad3356a68d7/pandas/errors/__init__.py). But many are not:
- tslibs.parsing.DateParseError
- tslibs.period.IncompatibleFrequency
- pandas/_config/config.py: OptionError
- pandas/core/base.py: DataError, GroupByError, SpeciicationError
- pandas/core/common.py: SettingWithCopyError/Warning
- pandas/core/computation/common/py: NameResolutionError
- pandas/core/computation/engine.py: NumExprClobberingError
- pandas/core/computation/ops.py: UndefinedVariableError
- pandas/core/indexes/base.py: InvalidIndexError
- pandas/coreindexing.py: IndexingError
- pandas/io/clipboard/exceptions.py: PyperclipException
- pandas/io/formats/css.py: CSSWarning
- pandas/io/msgpack: several exceptions
- pandas/io/pytables.py: lots of exceptions
- pandas/io/sql.py: SQLALchemyRequired, DatabaseError
- pandas/io/stata.py: several warnings
Do we want to move them all to the public pandas.errors
module?
Are there reasons that some can / should not be moved? Eg should the cython ones be defined in the cython file for performance?
Are there certain custom exceptions/warnings that we rather convert in a built-in one instead of publicly exposing them?
Do we want to move all the io related ones? (those modules are somewhat public)
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
brainstorming how to write tests for this, we could do something like:
We could use
ours
and blacklist internal-only classes for the parametrization in tests.test_errors.test_exception_importable@jbrockmendel
Hello, I just started to work on this and wanted to follow up on the this because I think I may be on the wrong page. Thank you for the code by the way.
I was initially thinking we would get the pandas exceptions that aren’t in
pandas.errors
and fail them, unless they’re intentionally not inpandas.errors
. There could be a list for the exceptions that are allowed to not be inpandas.errors
. But, I was also thinking that might be cumbersome to maintain and maybe the idea is not to enforce all exceptions inpandas.errors
.My idea doesn’t seem to match yours. I’m not quite following how we use
ours
to blacklist the parametrized exceptions intest_exception_importable