I was going to recommend using pyqver.py https://github.com/ghewgill/pyqver  to check for 2.4 syntax compatibility, but it doesn't catch this case.  The only tool I know of which catches this case is a the proprietary Pycharm python syntax checker.

It might be possible to add a flake8 plugin to catch this.  https://github.com/jcrocholl/pep8/blob/master/docs/developer.rst#contribute