-
Notifications
You must be signed in to change notification settings - Fork 10
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
Setup Python guidelines #81
Comments
let's scope it to existing tools/scripts written by infrastructure/tooling team which are in in the score repository |
This document serves as a draft guideline to be agreed upon by the Python developers to write clean, maintainable, and efficient code. This is not exhaustive but serves as a starting point to getting a comprehensive coding guideline document. -> Code style guidelinesFollow PEP 8 (Python’s style guide)
Naming conventions
Ref. - PEP 8 Naming Conventions Imports
-> Writing clean and readable codeAvoid deep nesting
Add comments and docstrings
Ref. - PEP 257, Google Python Style Guide Use type annotations
Ref. - PEP 484 Adopt modular design
Ref. - PEP 420 - Implicit Namespace Packages -> Avoid common pitfallsMutable default arguments
Handle Exceptions Gracefully
try:
result = 10 / divisor
except ZeroDivisionError:
print("Error: Division by zero is not allowed.")
Ref. - PEP 409 - Suppressing Exception Context Avoid hardcoding
-> Performance optimizationUse list comprehensions
Prefer built-in functions
->Testing and debuggingWrite unit tests
Use logging instead of print statements
->Version Control and CollaborationCommit messages
Document your code and API**
-> Tools and linters
-> References and further reading
|
Nice! My 2 cents:
|
Good first guideline! my notes would be:
|
Looking at some code in our current repository let's elaborate on comments and type hints a little:
|
The text was updated successfully, but these errors were encountered: