A powerful πͺ bash script to automate the process of maintaining code quality in Python projects.
The Python Code Quality Assurance Toolkit provides a bash script that automates various tasks related to maintaining code quality in Python projects. Whether you're an individual developer or part of a larger team, this tool offers a flexible solution to keep your Python code clean, efficient, and secure.
The script performs the following actions:
- Installs necessary Python packages for linting, formatting, and complexity analysis.
- Runs linters and formatters including flake8, pylint, pycodestyle, pydocstyle, autopep8, isort, and black on the Python project.
- Performs type checking with mypy.
- Scans the Python code for security vulnerabilities with Bandit.
- Analyzes the complexity of the Python code with Radon.
- Runs tests on the Python project with pytest.
- Checks code coverage of the tests.
- Checks for known security vulnerabilities in the installed dependencies with Safety.
- Generates a requirements file with pipreqs.
- Creates a
.gitignoreand optionally a.dockerignorefile. - Counts the lines of code in the Python project with cloc.
π₯ To install and set up the project, follow these steps:
- Clone the repository:
git clone https://github.com/username/project.git. - Navigate to the project directory:
cd project. - Ensure you have all the necessary Python packages installed. They're listed in the
requirements.txtfile. You can install them using pip:pip install -r requirements.txt.
You can run the script using the bash command in the terminal: bash code_quality.sh. Remember to replace the DIR variable in the script with the path to your Python project directory. The REQUIREMENTS variable should point to the location where you want to generate the requirements file.
The script uses pytest to run the tests in your Python project. Make sure you write comprehensive tests to ensure the correctness of your code.
- Python
- Bash
- And a range of Python libraries and tools including flake8, autopep8, isort, black, mypy, bandit, pipreqs, radon, pylint, pytest, coverage, safety, pycodestyle, pydocstyle, and cloc.
Contributions are welcome. Here's how you can contribute:
- Fork the project.
- Create your feature branch:
git checkout -b my-new-feature. - Commit your changes:
git commit -am 'Add some feature'. - Push to the branch:
git push origin my-new-feature. - Submit a pull request.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Contribute to the code and you will be here