Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: attrs #52152

Closed
wants to merge 11 commits into from
Closed

DEPR: attrs #52152

wants to merge 11 commits into from

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Mar 24, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

xref #51280

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine (looks like the warning may need filtering out in a test which uses the legacy pickle with attrs)

@jorisvandenbossche just to make sure we're all on the same page - is it only __finalize__ and metadata you need in geopandas?
From a look at the repo, it looks like there's a test that .attrs, and a benchmark, but other than that it doesn't look directly used?

if isinstance(left, (pd.DataFrame, pd.Series)):
left.attrs = {}
with tm.assert_produces_warning(FutureWarning, match=warn_msg):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably remove this if you're already filtering the warnings from the test?

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am -1 on deprecating attrs without first having more discussion about this.
(and ideally in a dedicated issue about it, that brings up a rationale for why we would remove this and what the alternatives are)

@jorisvandenbossche just to make sure we're all on the same page - is it only finalize and metadata you need in geopandas?

As I tried to explain on the issue (#51280 (comment)), those are unrelated. GeoPandas is a subclass, where we indeed make use of our subclassing capabilities (involving _metadata and __finalize__).
But attrs is a public API feature for end users providing some metadata functionality (that actually can avoid that you have to make a subclass for some basic metadata).

So with my GeoPandas-maintainer hat on, I don't have anything to do with attrs (and I also personally never use it). But this is public functionality that we should just treat as such and discuss why we would deprecate/remove that.

@@ -114,6 +114,7 @@ Deprecations
- Deprecated 'method', 'limit', and 'fill_axis' keywords in :meth:`DataFrame.align` and :meth:`Series.align`, explicitly call ``fillna`` on the alignment results instead (:issue:`51856`)
- Deprecated 'broadcast_axis' keyword in :meth:`Series.align` and :meth:`DataFrame.align`, upcast before calling ``align`` with ``left = DataFrame({col: left for col in right.columns}, index=right.index)`` (:issue:`51856`)
- Deprecated the 'axis' keyword in :meth:`.GroupBy.idxmax`, :meth:`.GroupBy.idxmin`, :meth:`.GroupBy.fillna`, :meth:`.GroupBy.take`, :meth:`.GroupBy.skew`, :meth:`.GroupBy.rank`, :meth:`.GroupBy.cumprod`, :meth:`.GroupBy.cumsum`, :meth:`.GroupBy.cummax`, :meth:`.GroupBy.cummin`, :meth:`.GroupBy.pct_change`, :meth:`GroupBy.diff`, :meth:`.GroupBy.shift`, and :meth:`DataFrameGroupBy.corrwith`; for ``axis=1`` operate on the underlying :class:`DataFrame` instead (:issue:`50405`, :issue:`51046`)
- Deprecated :meth:`DataFrame.attrs`, :meth:`Series.attrs`, to retain the old attribute propagation override ``__finalize__`` in a subclass (:issue:`51280`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that creating a subclass is the advice we want to give to users to retain the behaviour (generally users should be very wary about creating a custom subclass).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable. Did you have something else in mind?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you have something else in mind?

No, I am not aware of a good alternative. But so that's the part we should discuss before deprecating it.

@MarcoGorelli
Copy link
Member

OK thanks for clarifying

let's make a separate issue about this and discuss then, it's controversial enough it may warrant a pdep

@jbrockmendel jbrockmendel mentioned this pull request Mar 24, 2023
@MarcoGorelli MarcoGorelli added the Needs Discussion Requires discussion from core team before further action label Apr 11, 2023
@jbrockmendel
Copy link
Member Author

Mothballing, will revisit in a few months to see if the pro-attrs folks make progress on getting it fully working.

@jbrockmendel jbrockmendel added the Mothballed Temporarily-closed PR the author plans to return to label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mothballed Temporarily-closed PR the author plans to return to Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants