-
Notifications
You must be signed in to change notification settings - Fork 113
Python: Follow the PEP 8 style guide #1338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
First part available in PR: At the request of @sjanc
|
There are likely a handful of larger modifications needed to follow PEP8 properly. While each PEP rule are usually small and contained, some of the design choices in Python will conflict with that. For example regarding the variables not being used, there are some places where we access a variable directly from another module, e.g. the I think that is actually good for us, as we do not want to just follow the PEP8 syntax, we generally we should take this as an opportunity to find design choices (usually old ones) that are not very "pythonic" and refactor those. |
I feel tempted to put such variables in "common" files. So that it would be easy to manipulate them collectively if necessary. Despite everything, these are still suggestions. |
Depends on the situation. In many cases (including the aforementioned board files), I think we would benefit significantly from defining a class and then get/set the values via that instead, i.e. start becoming more object oriented in our designs rather than the current approach that is very imperative / C-like |
https://peps.python.org/pep-0008/ is the official (and probably most used) style guide for Python code. It has a long set of rules to help improve readability and reduce errors.
The autopts codebase should be updated to follow the PEP 8 style guide. To help this process, a linter should be applied. https://docs.astral.sh/ruff/ would be a good suggestion here, due to it's efficiency and flexibility.
Suggest approach:
We can modify and apply our own rules to the project. A common change is increasing the line length. PEP 8 by default only allows for maximum 79 characters per line: https://peps.python.org/pep-0008/#maximum-line-length and PEP 8 does say it's OK to increase to 99, but in the end it's up to use to decide. Some projects use 100 or 120.
The text was updated successfully, but these errors were encountered: