Skip to content

Commit

Permalink
misc cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Sep 21, 2023
1 parent 711c5dd commit 8119239
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 92 deletions.
87 changes: 1 addition & 86 deletions examples/pandas.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,95 +4,10 @@ logo = 'logo_pandas.png'
exec_failure = "fallback"
submodules = []
exclude = [
# "AssertionError"
"pandas._libs.properties.CachedProperty",
"pandas._config.config.CallableDynamicDoc",
"pandas._libs.index.BaseMultiIndexCodesEngine",
"pandas._libs.properties.AxisProperty",
# "ErrorHelper1-<class 'papyri.errors.SpaceAfterBlockDirectiveError'>
"pandas.core.algorithms.factorize",
"pandas.core.base.IndexOpsMixin.factorize",
# "ErrorNoExec-<class 'AssertionError'>
"pandas._libs.index.BaseMultiIndexCodesEngine",
# "ErrorNoExec-<class 'ValueError'>
"pandas.core.accessor.register_dataframe_accessor",
"pandas.core.accessor.register_index_accessor",
"pandas.core.accessor.register_series_accessor",
"pandas.core.accessor._register_accessor",
"pandas.core.arrays.base.ExtensionArray.take",
# "ErrorNoExec-<class 'papyri.errors.VisitTargetNotImplementedError'>
"pandas.plotting._core.PlotAccessor.kde",
# "ExecError-<class 'AssertionError'>
"pandas._libs.index.BaseMultiIndexCodesEngine",
# "ExecError-<class 'ValueError'>
"pandas.core.accessor.register_dataframe_accessor",
"pandas.core.accessor.register_index_accessor",
"pandas.core.accessor.register_series_accessor",
"pandas.core.accessor._register_accessor",
"pandas.core.arrays.base.ExtensionArray.take",
# "ExecError-<class 'papyri.errors.VisitTargetNotImplementedError'>
"pandas.plotting._core.PlotAccessor.kde",
# "NumpydocError-<class 'AssertionError'>
"pandas._libs.properties.CachedProperty",
"pandas._config.config.CallableDynamicDoc",
"pandas._libs.properties.AxisProperty",
# "NumpydocError-<class 'ValueError'>
"pandas.io.pytables.Table",
# "NumpydocError-<class 'numpydoc.docscrape.ParseError'>
"pandas.core.arraylike.array_ufunc",
"pandas.io.formats.info.BaseInfo.render",
"pandas.core.generic.NDFrame.set_axis",
"pandas.core.generic.NDFrame.replace",
"pandas.core.generic.NDFrame.isna",
"pandas.core.generic.NDFrame.isnull",
"pandas.core.generic.NDFrame.notna",
"pandas.core.generic.NDFrame.notnull",
# "ParseDesc-<class 'IndexError'>
"pandas._libs.algos.is_monotonic",
"pandas._libs.interval.intervals_to_interval_bounds",
"pandas.core.algorithms.duplicated",
"pandas._libs.tslibs.offsets.shift_month",
"pandas.core.dtypes.cast.astype_array_safe",
"pandas.core.window.expanding.Expanding.apply",
"pandas.core.window.expanding.Expanding.apply",
"pandas.core.window.expanding.Expanding.sum",
"pandas.core.window.expanding.Expanding.max",
"pandas.core.window.expanding.Expanding.min",
"pandas.core.window.expanding.Expanding.mean",
"pandas.core.window.expanding.Expanding.median",
"pandas.core.window.ewm.ExponentialMovingWindow.mean",
"pandas.core.window.rolling.Rolling.apply",
"pandas.core.window.rolling.Rolling.apply",
"pandas.core.window.rolling.Rolling.sum",
"pandas.core.window.rolling.Rolling.max",
"pandas.core.window.rolling.Rolling.min",
"pandas.core.window.rolling.Rolling.mean",
"pandas.core.window.rolling.Rolling.median",
"pandas.core.groupby.generic.DataFrameGroupBy.aggregate",
"pandas.core.groupby.generic.DataFrameGroupBy.transform",
"pandas.core.groupby.generic.SeriesGroupBy.aggregate",
"pandas.core.groupby.generic.SeriesGroupBy.transform",
"pandas.core.groupby.grouper.Grouping",
"pandas.core.internals.blocks.Block.astype",
"pandas.core.internals.blocks.Block.where",
"pandas.io.parsers.base_parser._get_na_values",
"pandas.core.reshape.melt.lreshape",
# "VisitTargetNotImplementedError
"pandas.plotting._core.PlotAccessor.kde",
"pandas.io.gbq.read_gbq",
"pandas.core.frame.DataFrame.to_gbq",
"pandas.core.indexes.base.Index.drop_duplicates",
"pandas.plotting._core.hist_frame",
# "ExecError-<class 'ValueError'>": [
"pandas._testing._io.network",
# "np.bool_" is seen as a reference
"pandas._libs.lib.is_bool_list",
# Imbalanced backticks
"pandas.core.common.pipe"
]
[pandas.expected_errors]
ValueError = [
"pandas.io.gbq:read_gbq", gen.py:2041
"pandas.io.gbq:read_gbq",
"pandas.io.pickle:to_pickle",
"pandas.core.frame:DataFrame.to_gbq",
"pandas.core.generic:NDFrame.to_pickle",
Expand Down
14 changes: 8 additions & 6 deletions papyri/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
del self._expected_unseen[self._qa]
else:
self._errors.setdefault(ename, []).append(self._qa)
self.log.exception(f"Unexpected error (ctxmgr, {self._qa})")
self.log.exception(f"Unexpected error {self._qa}")
if not self.config.early_error:
return True
expecting = self._expected_unseen.get(self._qa, [])
Expand Down Expand Up @@ -1806,11 +1806,13 @@ def helper_1(
Can be any kind of object
"""
item_docstring: str = target_item.__doc__
if item_docstring is not None:
item_docstring = dedent_but_first(item_docstring)
builtin_function_or_method = type(sum)

if isinstance(target_item, ModuleType):
api_object = APIObjectInfo(
"module", target_item.__doc__, None, target_item.__name__, qa
"module", item_docstring, None, target_item.__name__, qa
)
elif isinstance(target_item, (FunctionType, builtin_function_or_method)):
sig: Optional[str]
Expand All @@ -1822,17 +1824,17 @@ def helper_1(
sig = None
try:
api_object = APIObjectInfo(
"function", target_item.__doc__, sig, target_item.__name__, qa
"function", item_docstring, sig, target_item.__name__, qa
)
except Exception as e:
raise type(e)(f"For object {qa!r}")
elif isinstance(target_item, type):
api_object = APIObjectInfo(
"class", target_item.__doc__, None, target_item.__name__, qa
"class", item_docstring, None, target_item.__name__, qa
)
else:
api_object = APIObjectInfo(
"other", target_item.__doc__, None, target_item.__name__, qa
"other", item_docstring, None, target_item.__name__, qa
)
# print_("Other", target_item)
# assert False, type(target_item)
Expand All @@ -1843,7 +1845,7 @@ def helper_1(
elif item_docstring is None and isinstance(target_item, ModuleType):
item_docstring = """This module has no documentation"""
try:
sections = ts.parse(dedent_but_first(item_docstring).encode(), qa)
sections = ts.parse(item_docstring.encode(), qa)
except (AssertionError, NotImplementedError) as e:
self.log.error("TS could not parse %s, %s", repr(qa), e)
raise type(e)(f"from {qa}") from e
Expand Down

0 comments on commit 8119239

Please sign in to comment.