opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Naming Convention Violations in OpenCV Python Bindings

Open gabemorris12 opened this issue 11 months ago • 1 comments

Naming conventions are important for readability, and as the title implies, this package does not comply with the PEP 8 naming conventions. As a result, the code can be harder to read, maintain, and integrate with other Python projects that follow standard conventions, leading to inconsistencies, increased learning curves for new developers, and potential for misinterpretation or errors.

A practical solution would be to introduce name aliases to allow backwards compatibility, but also give the choice to pursue the style of modern projects. Another option would be to do something like the threading module does:

def current_thread():
    """Return the current Thread object, corresponding to the caller's thread of control.

    If the caller's thread of control was not created through the threading
    module, a dummy thread object with limited functionality is returned.

    """
    try:
        return _active[get_ident()]
    except KeyError:
        return _DummyThread()

def currentThread():
    """Return the current Thread object, corresponding to the caller's thread of control.

    This function is deprecated, use current_thread() instead.

    """
    import warnings
    warnings.warn('currentThread() is deprecated, use current_thread() instead',
                  DeprecationWarning, stacklevel=2)
    return current_thread()

Are there any thoughts on addressing this issue?

gabemorris12 avatar Jan 23 '25 19:01 gabemorris12

I think this is due to the C++ origins of this library. I usually disable pylint warning for those functions:

# pylint: disable=C0103
def keyPressEvent(self, event):
   [ . . . ]
# pylint: enable=C0103

lucalista avatar Nov 30 '25 21:11 lucalista