Dominic Littlewood <11dlittlew...@gmail.com> added the comment:

I've slightly adjusted the script to check for module-level imports not at the 
top of the file. If we permit things like this:

if condition:
    import module
else:
    do_something_sensible()

as long as they are at the top of the file, it seems that only one in ten 
modules have a problem. Which is better but not great.

A common pattern which breaks the rules is this:

# Large amounts of code here

if __name__ == '__main__':
    import unittest
    unittest.main('test/test_thisfile')

although that by no means accounts for all of the problems.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38297>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to