camel-snake-pep8
camel-snake-pep8 copied to clipboard
It wants to rename `Exception` to `exception` and ends up in an infinite loop if I tell it `no`.
There are sections in a code base I'm currently cleaning up which simply do
raise Exception("foobar")
or
try:
...
except Exception:
...
camel-snake-pep8 wants to rename Exception here to exception which is syntactically wrong.
Types should be excluded from being renamed, as PEP8 recommends them to be camel case
Oh and when I select "no" it ends up in a loop.
Okay, I've figured out that it's got something to do with using loguru
.
A loguru
logger has a method called exception
which is muddled up by either Rope or camel-snake-pep8 with the builtin Exception
class.
Investigating...
This is really weird. For some reason in one of my programs the Rope Worder seems to detect the builtin Exception
type as coming from loguru
. As mentioned, there is a method exception
(with a small letter e
) in the loguru
logger. I've tried to reproduce this error by building a small example program that utilizes loguru
but I wasn't able to reproduce it. The small program gets refactored as expected. There must be something else interfering with camel-snake-pep8
or rope
...
I've given up. Unfortunately, I can't continue using camel-snake-pep8
because of the loop bug. When I tell it not to rename Exception
to exception
it ends up in an endless loop because it re-detects the potential renaming of Exception
.
I tried a small example based on your description above and I couldn't reproduce the problem either. As a possible workaround, if there are only one or two places where that kind of error occurs you could temporarily comment-out that code or rename to something like ExceptionXXXX
while you convert the other variables.
I now get the exact same problem but with changing False to false
@nj-kore, do you have a code snippet which reproduces the problem?