You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
I'm creating this issue for discussion about the style guide in the project, that has to be developed.
I would suggest thinking carefully before you decide to switch to one style or another. I've checked the QGIS repo and even there is no consistency, for example here. I've checked the top most downloaded plugins about camelOrPascalCase vs pep8 recommendation: Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.. The conclusions from my investigations are: I see a lot of diversity :) . Either lack of consistency or one of the two styles is used. However, it seems there is a little preference towards QT style.
IMHO when dealing with QGIS/QT, it's better to follow their style guide, when everything is depending so much on them. Otherwise mixing is inevitable in the same file. For lib files that are completely separate and independent (therefore might be reused outside the current project), I would use the PEP8 recommendation. PEP8 is not a religious book, even python core libraries break the style guide: logging.getLogger(name).
As for PEP484, I see that in the beginning, the syntax might seem a bit funky to people who are not fully in the CS field. However, in the long term, I think it pays off as smart and easy documentation. Even for beginners, who often use IDEs, can get type checking for free, therefore making it easier to contribute with fewer bugs. PEP484 is a relatively new feature in the Python world (v3.5), QGIS supports Python 3 since Feb 2018 and it's understandable why it's not widely adopted in the community yet. So at least for separate, completely independent files, I would suggest to use it.
As a short summary, I would suggest the following convention.
max chars per line: 119, preferably 80
use of PEP484 as much as possible to secure maintainability and the need to write and check the documentation.
classes that interact with Qgis/Qt should use camelCase for their property, method and variable names.
QT widgets ids have to be in camelCase to match the QT convention; They should end with the widget type name (*Label, *LineEdit, *Button).
event callbacks should be marked as private, as we do not want to pollute the class interface.
Of course, all of this is my subjective opinion and it is based on writing and investigating a few public and private QGIS plugins. Feel free to disagree but I think it's a good starting point for a discussion.
I'm creating this issue for discussion about the style guide in the project, that has to be developed.
I would suggest thinking carefully before you decide to switch to one style or another. I've checked the QGIS repo and even there is no consistency, for example here. I've checked the top most downloaded plugins about camelOrPascalCase vs pep8 recommendation:
Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.
. The conclusions from my investigations are: I see a lot of diversity :) . Either lack of consistency or one of the two styles is used. However, it seems there is a little preference towards QT style.IMHO when dealing with QGIS/QT, it's better to follow their style guide, when everything is depending so much on them. Otherwise mixing is inevitable in the same file. For lib files that are completely separate and independent (therefore might be reused outside the current project), I would use the PEP8 recommendation. PEP8 is not a religious book, even python core libraries break the style guide: logging.getLogger(name).
As for PEP484, I see that in the beginning, the syntax might seem a bit funky to people who are not fully in the CS field. However, in the long term, I think it pays off as smart and easy documentation. Even for beginners, who often use IDEs, can get type checking for free, therefore making it easier to contribute with fewer bugs. PEP484 is a relatively new feature in the Python world (v3.5), QGIS supports Python 3 since Feb 2018 and it's understandable why it's not widely adopted in the community yet. So at least for separate, completely independent files, I would suggest to use it.
As a short summary, I would suggest the following convention.
Of course, all of this is my subjective opinion and it is based on writing and investigating a few public and private QGIS plugins. Feel free to disagree but I think it's a good starting point for a discussion.
The text was updated successfully, but these errors were encountered: