GispoCoding / flake8-qgis

Flake8 plugin for QGIS python plugins
MIT License
6 stars 4 forks source link

Add QGS107: don't import iface, instead pass it as an argument #12

Closed Joonalai closed 3 months ago

Joonalai commented 3 months ago

This PR adds another rule QGS107: "Don't import QgisInterface instance (iface). Instead pass it as an argument" alongside with QGS105: "Don't pass QgisInterface as an argument". These rules cancel each other's out and the user must choose which approach to use.

Fixes #8.

Joonalai commented 3 months ago

@LKajan or @ismogis could you review this? And what do you think, do we need this new rule QGS107 or is just the edigint of the documentation sufficient in this case? New rule makes it practically impossible to use the plugin without ignoring one of its rules.

LKajan commented 3 months ago

Thanks for the proposal! In my opinion there are no reasons to prevent importing iface from the utils module and therefore the necessity of the proposed QGS107 is questionable. And since adding this new rule forces users to ignore either one of these related rules I think it is better to solve this other way.

I'm in favor of adding just better documentation or reasoning for QGS105. I created a new ticket for that #13.

Joonalai commented 3 months ago

I agree, the need for this new rule is not clear (as long as iface is importable from utils). I'll close this for now.