[pyqgis cookbook] update formatting and fix warnings