Skip to content

Add snake_cased function aliases in __init__.py #136

Description

@TheGittyPerson

The standard naming convention for Python function names is snake_case, as stated in Python's official style guide. Currently, the functions in __init__.py use lowerCamelCase (aka mixedCase):

def getHandler(access_token=None, **kwargs): ...
def getHandlerLite(access_token=None, **kwargs): ...
def getHandlerCore(access_token=None, **kwargs): ...
def getHandlerPlus(access_token=None, **kwargs): ...
def getHandlerAsync(access_token=None, **kwargs): ...
def getHandlerAsyncLite(access_token=None, **kwargs): ...
def getHandlerAsyncCore(access_token=None, **kwargs): ...
def getHandlerAsyncPlus(access_token=None, **kwargs): ...

Some code editors may highlight calls to these functions due to the styling issue, and styling-obsessed developers such as myself or teams who just prefer style consistency in their code would appreciate using the standard naming convention. Most other modules (specifically the ones whose names begin with handler) also have this issue, but we could just start with this one first.

With the concern of backwards compatibility, we can create aliases for these functions instead. The implementation should be fairly simple:

def get_handler(access_token=None, **kwargs):
    """Create and return Handler object."""
    return Handler(access_token, **kwargs)

def getHandler(access_token=None, **kwargs):
    """Create and return Handler object."""
    return Handler(access_token, **kwargs)
    # or:
    return get_handler(access_token, **kwargs)

Cons:

  • Can be confusing to users who might think the different aliases have some different functionality.
    • Solution: we can note in the documentation that the functions and their aliases are equivalent.
  • Namespace pollution
  • I realized the problem was not only in __init__.py only after writing this issue.

I can open a PR for this if this change is ok. If there are other reasons that this change wouldn't be ideal, or if there is a better way to do this, please let me know.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions