detect.py: fix some flake8 and pylint reports