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

use keyword only args where appropriate #27544

Closed
jreback opened this issue Jul 23, 2019 · 9 comments
Closed

use keyword only args where appropriate #27544

jreback opened this issue Jul 23, 2019 · 9 comments
Labels
Deprecate Functionality to remove in pandas Enhancement Refactor Internal refactoring of code

Comments

@jreback
Copy link
Contributor

jreback commented Jul 23, 2019

we should use keyword only arguments for some of our functions that have large numbers of kwargs to make it harder to make mistakes in the calling conventions, a prime example is [read_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html?highlight=read_csv#pandas.read_csv].

likely we want a signature

def read_csv(self, filepath_or_buffer, *, .......

IOW all args, except for the first should be kwargs.

We could further modify a fair number of functions, so will treat this as a tracking issue.

@jreback jreback added IO Data IO issues that don't fit into a more specific label 2/3 Compat labels Jul 23, 2019
@jreback jreback added this to the Contributions Welcome milestone Jul 23, 2019
@WillAyd
Copy link
Member

WillAyd commented Jul 23, 2019

Good idea - is this supported in Py3.5?

@jreback
Copy link
Contributor Author

jreback commented Jul 23, 2019

Good idea - is this supported in Py3.5?

yes

@alexitkes
Copy link
Contributor

I like this. I can try for read_html, read_json and some other I/O functions. Should all optional arguments be keyword-only?

@simonjayhawkins
Copy link
Member

isn't this a breaking api change?

@jreback
Copy link
Contributor Author

jreback commented Jul 23, 2019

isn't this a breaking api change?

yes, but IMHO a minor one, you almost always use keyword args with the functions with many args anyhow

@simonjayhawkins
Copy link
Member

isn't this a breaking api change?

yes, but IMHO a minor one, you almost always use keyword args with the functions with many args anyhow

so if we go for straight break, we should do this for 1.0?

@jreback
Copy link
Contributor Author

jreback commented Jul 23, 2019

yes this would be for 1.0

@TomAugspurger
Copy link
Contributor

For posterity, in #27573 we're using a decorator to deprecate passing keyword arguments positionally. This not be API breaking.

@jbrockmendel jbrockmendel added the Code Style Code style, linting, code_checks label Sep 22, 2020
@mroeschke mroeschke added Refactor Internal refactoring of code Deprecate Functionality to remove in pandas and removed API Design Code Style Code style, linting, code_checks IO Data IO issues that don't fit into a more specific label labels Jul 10, 2021
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
@jbrockmendel
Copy link
Member

we've done a lot of this and have gotten into the habit. closing as complete.

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 Enhancement Refactor Internal refactoring of code
Projects
No open projects
IO Method Robustness
Awaiting triage
Development

No branches or pull requests

7 participants