AndersMalmgren / FreePIE

Programmable Input Emulator
644 stars 144 forks source link

"continousRotation" name typo #21

Closed jamiebull1 closed 10 years ago

jamiebull1 commented 10 years ago

The method name continousRotation should probably be continuousRotation as it's crying out for being mistyped as it stands.

AndersMalmgren commented 10 years ago

Thanks, yeah, saw that a while back. It's unfortunate because if we fix it now a lot of scripts out there will fail. Maybe it's the price we will have to pay. Let me get back to you.

jamiebull1 commented 10 years ago

Maybe copy it, fix the name on one version, and add a deprecation warning message to the other for a few releases? On May 2, 2014 8:07 AM, "Anders Malmgren" notifications@github.com wrote:

Thanks, yeah, saw that a while back. It's unfortunate because if we fix it now a lot of scripts out there will fail. Maybe it's the price we will have to pay. Let me get back to you.

— Reply to this email directly or view it on GitHubhttps://github.com/AndersMalmgren/FreePIE/issues/21#issuecomment-41997424 .

AndersMalmgren commented 10 years ago

Or hide the deprecated version from code completion. That way no new scripts will use them but the old scripts will still run

jamiebull1 commented 10 years ago

That sounds like a good approach. On May 2, 2014 11:07 AM, "Anders Malmgren" notifications@github.com wrote:

Or hide the deprecated version from code completion. That way no new users will use them but the scripts will still run

— Reply to this email directly or view it on GitHubhttps://github.com/AndersMalmgren/FreePIE/issues/21#issuecomment-42012671 .

AndersMalmgren commented 10 years ago

Can this do it?

Deprecated

jamiebull1 commented 10 years ago

Is filters.continousRotation calling filters.continuousRotation there? The deprecation warning looks right, but to avoid breaking backwards compatibility the typo function should just pass through the arguments to the correct one. It looks like that's what your doing but just making sure.

So you end up with:

import warnings

    class filters:

        ...

        def continousRotation(input_pos):
            ''' This function will be deprecated from the next major version. Use continuousRotation instead '''
            warnings.warn("This function will be deprecated from v2.0.0", PendingDeprecationWarning)
            return continuousRotation(input_pos)

        def continuousRotation(input_pos):
            ''' Proper doc string '''
            # Whatever the code is
            return continuous_pos
AndersMalmgren commented 10 years ago

You can use either continuousRotation or continousRotation but the latter will result in warning

jamiebull1 commented 10 years ago

Perfect.

AndersMalmgren commented 10 years ago

Oh, and warnings wont stop the script, just output in error window