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

Ensure some keyword arguments are passed as such #223

Open
jooola opened this issue Jun 26, 2023 · 2 comments
Open

Ensure some keyword arguments are passed as such #223

jooola opened this issue Jun 26, 2023 · 2 comments
Labels
enhancement New feature or request pinned

Comments

@jooola
Copy link
Member

jooola commented Jun 26, 2023

Feature Request

In the current API, we define functions with arguments without forcing those arguments to be keyword arguments.

This is fine as long as we don't introduce new fields in the middle of the argument list.

For example:

def get_list(
    name=None,
    architecture=None,
    page=None,  
    per_page=None, 
):
    pass

get_list(name, architecture, 2, 100)

If we add an extra field, we want to keep the organization logic and put the argument before the pagination argument:

 def get_list(
     name=None,
     architecture=None,
+   some_field=None,
     page=None,  
     per_page=None, 
 ):
     pass

But the above would introduce a breaking change for the function call we previously defined:

get_list(name, architecture, 2, 100) # some_field=2, page=100

Describe the solution you'd like

In Python, we can set at which point in the argument list, the argument MUST be keyword arguments:

def get_list(
    name=None,
    *,
    architecture=None,
    page=None,  
    per_page=None, 
):
    pass

This will force the users to use kwargs like the following:

get_list(name, architecture=architecture, page=2, per_page=100)

Using this will allow us adding fields without risk of breaking someone's code.

This is breaking change, this can only happen in v2.0.0.

@jooola jooola added this to the v2.0.0 milestone Jun 26, 2023
@jooola jooola added the enhancement New feature or request label Jul 18, 2023
@github-actions
Copy link

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the Stale label Oct 16, 2023
@jooola jooola removed the Stale label Oct 17, 2023
Copy link

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

1 participant