Skip to content

DEPR: allowing non-class returns for _constructor etc #52420

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

Closed
wants to merge 23 commits into from

Conversation

jbrockmendel
Copy link
Member

I'd be OK with leaving out the __init_subclass__ bit and just have this be in the docs.

Comment on lines +651 to +656
warnings.warn(
"pandas subclass support is deprecating allowing _constructor "
"that does not return a class.",
FutureWarning,
stacklevel=find_stack_level(),
)
Copy link
Member

Choose a reason for hiding this comment

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

does this raise a warning all the time, with no option to silence it?

just wondering if there's a way to do this without having to always raise a warning, and if not, if the warning should advise to just use filterwarnings to suppress the message because there's no workaround

Copy link
Member Author

Choose a reason for hiding this comment

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

does this raise a warning all the time, with no option to silence it?

Yes. I tried having it check and only raise if _constructor_foo doesn't return a class but couldn't get that working.

just wondering if there's a way to do this without having to always raise a warning, and if not, if the warning should advise to just use filterwarnings to suppress the message because there's no workaround

Makes sense. Or as mentioned in the OP this could be doc-only.

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.

My reading of the issue #51772 is not that there is any kind of agreement that we actually want to do this.
I actually asked clarification of the motivation and provided arguments why I think this is not such a useful change (#51772 (comment)), and since then got not even a reply to that.

@jbrockmendel
Copy link
Member Author

and since then got not even a reply to that.

We've had this discussion and I decline to go around in circles with you on this.

@jreback
Copy link
Contributor

jreback commented Apr 13, 2023

+1 on deprecating and making these class only

when we originally did this there was NO intention or reason to ever make these callable. it's not necessary and just too flexible.

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Apr 17, 2023

We've had this discussion and I decline to go around in circles with you on this.

Sorry to chime in, but can I ask that we be a little more empathetic in written conversation please? This kind of tone can be off-putting to any newcomer who might be reading along (as well as to anyone else, really)

I'm well aware that I'm not always the best or most empathetic communicator myself, I'm just saying - let's all try to work on this

@MarcoGorelli
Copy link
Member

I'm well aware that I'm always the best or most empathetic communicator myself

ah, why am I so bad at typing, of course I meant to write "I'm not always" 🤦 have edited


Anyway, back to the issue at hand.

I've re-read through #51772. If this was never meant to work in the first place, and it was never documented to work, then it seems perfectly fine to deprecate. Especially if it simplifies the codebase and if it's not technically difficult to workaround in geopandas

Regarding the point that it'd be easy to write a code check to ensure that .constructor is only ever used assuming it's a class - I'm not sure I agree. At least, not statically, and anything involving inspecting annotations tends to be noticeably slower

@MarcoGorelli
Copy link
Member

How do we move forwards here? @jorisvandenbossche would you want a vote on this? A discussion in the community call?

@MarcoGorelli
Copy link
Member

shall we hold off from merging main until we find a way forwards in the discussion in the issue?

@jbrockmendel
Copy link
Member Author

shall we hold off from merging main until we find a way forwards in the discussion in the issue?

Is the CI clogged? If so, sure. Otherwise I don't see much downside to keeping this up-to-date. Easier to rebase periodically than all at once.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Jun 8, 2023
@mroeschke
Copy link
Member

+1 on moving forward with this especially if there's a reasonable workaround in geopandas

@jorisvandenbossche
Copy link
Member

@mroeschke the substantial discussion is at #51772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Stale Subclassing Subclassing pandas objects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: require _constructor/_constructor_sliced to return a class
5 participants