A big hole in Python's checkers

26 views
Skip to first unread message

Edward K. Ream

unread,
Apr 8, 2024, 5:17:16 AM4/8/24
to leo-editor

There is a surprising hole in Python's checkers: Ruff, Mypy, Pylint, and Pyflakes.


The test file


Consider the following file:


class Test:

    __slots__ = ('good',)


def main():

    t = Test()

    print(t.bad)

        

main()


When executing this file, Python throws an AttributeError as expected: the instance t of the Test class has no "bad" attribute. But none of the checkers listed above detect this error! 


Iirc Pylint used to discover at least some of these errors, but it no longer does.


Summary


I have filed Ruff issue #10833 on this topic. All the checkers fail with or without the __slots__ statement.


Leo issue #3852 suggests creating a tool to find such errors.


Edward

Edward K. Ream

unread,
Apr 8, 2024, 5:44:37 AM4/8/24
to leo-e...@googlegroups.com
On Mon, Apr 8, 2024 at 4:17 AM Edward K. Ream wrote:

There is a surprising hole in Python's checkers: Ruff, Mypy, Pylint, and Pyflakes.

Oh Joy, the Ruff devs plan to implement static type checking.


See the response to Ruff issue  #10833


As a result, Leo issue #3852 is moot. I have just closed it.

Edward
Reply all
Reply to author
Forward
0 new messages