I've recently come across a Python library on GitHub. The library is great, but contains one glaring typo in a function name. Let's call it dummy_fuction()
while it should be dummy_function()
. This function is definitely "in the wild" and most likely used in embedded systems.
The first thing that springs to mind is to add a second version of the function with the correct name and add a deprecation warning to the first version for the next release.
Three questions:
- Could the approach above have any unintended consequences?
- Is there a standard approach to this kind of problem?
- How long should any deprecation warning be left in place?
Best Answer
First and foremost, the policy depends on the maintainer.
I think your question is interesting, but mostly opinion-based.
In my personal opinion your approach is sound - rename the function and leave the misspelled version as a deprecated artifact, redirecting to the correct one.
It could break the code eg. if someone couldn't stand the misspelling either and implemented a renamed version of their own. Now there'll be a name clash once they update the library.
Don't make spelling mistakes when writing a library ;)
I believe the deprecation should be left in place until the next major release (when the first digit in version number is increased).
This is when some - justified - backward compatibility breaking is tolerable, and it's up to the library users to ensure their code still builds fine.
Just make sure to point it out in the changelog: guys, if you used
dummy_fuction
, replace it withdummy_function
everywhere and you're good to go.If the library isn't versioned, as it might be - it makes a good case to start versioning it.