BettyPy is a Python style guide for the Betty programming language. It enforces best practices and ensures clean, readable, and maintainable code.
Click to expand
BettyPy provides a set of rules and guidelines for writing Python code in the Betty programming language. It helps developers maintain consistent coding standards and improve code quality.
| Feature | Description |
|---|---|
| Empty files | Detects and warns about empty files in the project. |
| Line Length | Ensures that lines do not exceed 80 characters for better readability. |
| Indentation | Enforces 4 spaces per indentation level to maintain consistent formatting. |
| Docstring | Checks for missing or improperly formatted docstrings in code. |
| Comment | Ensures comments are clear, properly formatted, and start with a space. |
| Codetag | Detects TODO, FIXME, and other annotations in the code. |
| Import | Identifies unused imports and suggests their removal. |
| Last Line | Ensures the file ends with a newline character. |
| Function Name | Verifies that function names follow the snake_case naming convention. |
| Unused Function | Detects unused functions in the code. |
| Variable Name | Ensures variable names follow the snake_case naming convention. |
| Unused Variable | Detects unused variables in the code. |
To install BettyPy on Linux, follow these steps:
$ git clone https://github.com/ItsZmainDev/BettyPy.git
$ cd BettyPy
$ sudo ./install.shNote: Windows support is experimental and may not work as expected. Use at your own risk. To install BettyPy on Windows, follow these steps:
$ git clone https://github.com/ItsZmainDev/BettyPy.git
$ cd BettyPy
$ install_windows.batRun BettyPy on your Python file with the following command:
$ bettypy <path_to_your_python_file># This is an example Python file
def function_example():
# print("cette ligne est trop longue et dépasse 80 caractères, ce qui est inacceptable dans le style de codage de Betty.")
print("cette ligne n'est pas indentée correctement et doit être corrigée.")
####test$ bettypy example.pyroot@eddc83f1bb46:/home/ubuntu/BettyPy# bettypy tests/testfile.py
[2025-04-14 22:30:46] [INFO] tests/testfile.py - Starting analysis...
[2025-04-14 22:30:46] [WARNING] tests/testfile.py:4: line too long (125 characters)
[2025-04-14 22:30:46] [WARNING] tests/testfile.py:5: line too long (82 characters)
[2025-04-14 22:30:46] [WARNING] tests/testfile.py:7: comment should start with a space after #
[2025-04-14 22:30:46] [WARNING] tests/testfile.py:7: comment too short (4 characters)
[2025-04-14 22:30:46] [WARNING] tests/testfile.py: file should end with a new line
[2025-04-14 22:30:46] [WARNING] tests/testfile.py:3: Function 'def function_example():' is missing a docstring.
[2025-04-14 22:30:46] [WARNING] tests/testfile.py:: line should be indented with tabs, not spaces. Please use tabs for indentation.
[2025-04-14 22:30:46] [ERROR] Analysis completed with 7 errors.
root@eddc83f1bb46:/home/ubuntu/BettyPy# - Linux or macOS (Windows support is experimental)
We welcome contributions to improve BettyPy! Follow these steps to get started:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix:
$ git checkout -b my-feature
- Make your changes and commit them with a clear message:
$ git commit -m "Add my feature" - Push your changes to your fork:
$ git push origin my-feature
- Open a pull request to the main repository.
- Your changes will be reviewed, and if approved, merged into the main branch.
- For build the project, you need to use the command:
$ go build cmd/bettypy/main.go
- Found a bug or have a feature request? Create an issue in the GitHub repository.
- Provide a clear and detailed description of the problem or suggestion.
- Include relevant details, such as steps to reproduce the issue or examples of the desired feature.
- If you'd like to work on the issue, assign it to yourself or request assignment.
- Once your work is complete, submit a pull request referencing the issue.
- All pull requests are reviewed by project maintainers.
- Feedback will be provided if changes are needed.
- Once approved, your contribution will be merged, and you’ll be credited for your work.
Thank you for helping improve BettyPy!
Holberton School
This project was inspired by the Betty style guide for C, developed at Holberton School. BettyPy was created as a personal project to bring similar coding standards to Python. If it can help students or developers, all the better!
- Martin Clement - Github Profile
This project is licensed under the Mozilla Public License 2.0. See the LICENSE file for details.
