Detect naming typos (AttributeError) in function names

Thomas Passin list1 at tompassin.net
Tue Nov 7 07:35:18 EST 2023


On 11/7/2023 2:48 AM, Christian Buhtz via Python-list wrote:
> Hello Dieter,
> 
> thanks for your reply.
> 
> Am 06.11.2023 19:11 schrieb Dieter Maurer:
>> One option is a test suite (--> Python's "unittest" package)
>> with a sufficiently high coverage (near 100 %).
> 
> Yes, that is the primary goal. But it is far away in the related project.
> 
> I got a hint that "pylint" is able to detect problems like this.

mypy can detect typos in names by noticing that they haven't been 
declared.  For example, if you have a class NewClass(BaseClass), and 
BaseClass has a method findme(), but you call it as findMe(), mypy will 
tell you findMe does not exist in BaseClass.  It can be annoying to get 
the options set right so you don't get too many undesired hits, but it's 
certainly doable.  mypy can be slow, depending on your code.

You could also simply run py_compile, which will try to compile the 
code.  It will stop at the first error it finds.



More information about the Python-list mailing list