Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kamilrybacki/basicpythonproject
My template for Python projects
https://github.com/kamilrybacki/basicpythonproject
Last synced: 12 days ago
JSON representation
My template for Python projects
- Host: GitHub
- URL: https://github.com/kamilrybacki/basicpythonproject
- Owner: kamilrybacki
- License: mit
- Created: 2023-07-23T07:45:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-19T12:21:40.000Z (5 months ago)
- Last Synced: 2024-06-19T22:00:19.294Z (5 months ago)
- Language: Python
- Size: 266 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Basic Python Project
## Overview
This project is a basic Python application designed to provide a template for building Python-based projects. It includes essential configurations for code linting, testing, and dependency management. The repository is structured to facilitate easy project setup and maintain good coding practices.
## Project Structure
```bash
..
│
├── LICENSE # License file for the project
├── README.md # Project README file
├── .gitignore # Specifies files and directories to be ignored by Git
├── pyproject.toml # PEP 518 configuration file for PEP 517 build system
├── .pre-commit-config.yaml # Configuration file for pre-commit hooks
├── Makefile # Makefile for common project tasks
├── src/
│ └── main.py # Main Python source file
├── tests/ # Directory for test files
└── .github/
└── workflows/
└── lint-code.yml # GitHub Actions workflow for code linting
└── requirements.txt # List of dependencies for project utilities (for local and CI use)
```### Package dependencies
The package dependencies are managed using the `pyproject.toml` file. This file defines the following types of dependencies:
- **Main package dependencies**: Packages required for the main application (*project.dependencies*),
- **Development dependencies**: Packages required for development and testing purposes (*project.optional_dependencies.develop*),
- **Test suite dependencies**: Packages required for running tests (*project.optional_dependencies.test*),
- **Documentation dependencies**: Packages required for generating documentation (*project.optional_dependencies.docs*).To install explicitly one or more of these dependencies, use the following command:
```bash
flit install --deps=
```## Getting Started
### Prerequisites
- Python 3.12 or higher
- `pip` (Python package installer)### Installation
1. **Clone the repository:**
```bash
git clone https://github.com/yourusername/BasicPythonProject.git
cd BasicPythonProject
```2. Run the `setup-project` script to set up the project:
```bash
make setup-project
```This script will install the project dependencies and set up the pre-commit hooks.
### Running the Application
To run the main application script:
```bash
python src/main.py
```## Code Quality and Linting
- **Ruff**: Ruff is a Python project template that includes several tools for code quality and linting,
- **Mypy** is used for static type checking.To run linters manually:
```bash
make lint
```## Code Quality Standards
The project enforces several code quality standards to ensure consistent and high-quality code.
The standards are defined through the use of tools such as Flake8, Pylint, and Mypy.
In other cases - the official Python style guide (PEP 8) is followed.Below are the details of the enforced standards:
## Ruff
```ini
[tool.ruff]
target-version = "py312" # Target Python version is 3.12
line-length = 120 # Maximum line length increased to 120
tab-size = 4 # Indentation width is set to 4 spaces[tool.ruff.format]
indent-style = "space" # Indentation style is set to spaces instead of tabs
quote-style = "double" # Double quotes are used for strings[tool.ruff.lint]
fixable = ["ALL"]
ignore = [ # Ignored linting rules
"D100", # missing-module-docstring
"D101", # missing-class-docstring
"D102", # missing-function-docstring
"D103", # missing-function-docstring
"F401", # Unused imports (can be adjusted based on need)
]select = ["C90", "I", "E", "F", "N", "B", "A", "Q", "W", "RUF". "TID"] # Selected linting rules
exclude = ["env/", "build/"][tool.ruff.lint.mccabe]
max-complexity = 5 # Maximum cyclomatic complexity set to 5[tool.ruff.lint.isort]
force-wrap-aliases = true # Force wrapping of import aliases[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double" # Double quotes for docstrings[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all" # Ban all relative imports - use absolute imports
```The selected linting rules are:
- **(C90)** *mccabe*: Cyclomatic complexity
- **(I)** *isort*: Import sorting
- **(E)** *pycodestyle*: PEP 8 style guide violations (errors)
- **(F)** *pyflakes*: Logical errors in code
- **(N)** *pep8-naming*: Naming conventions
- **(B)** *flake8-bugbear*: Additional checks for common issues
- **(A)** *flake8-builtins*: Checks for Python built-in shadowing
- **(Q)** *flake8-quotes*: Quote consistency
- **(W)** *pylint*: Code quality and style guide violations (warnings)
- **(RUF)** *ruff*: Ruff-specific rules
- **(TID)** *flake8-tidy-imports*: Import sorting and grouping### Mypy
Mypy is used for type checking to ensure that the code adheres to the specified type annotations. The `mypy.ini` file includes:
- **Python Version**: The code is checked against Python version 3.12.
- **Exclusions**: Directories like `env/` and `build/` are excluded from type checking.```ini
disallow_untyped_defs = true # Disallow untyped function definitions
disallow_any_unimported = true # Disallow unimported modules
no_implicit_optional = true # Disallow implicit Optional
check_untyped_defs = true # Check untyped definitions
warn_unused_ignores = true # Warn about unused # type: ignore comments
warn_return_any = true # Warn about missing return type annotations
show_error_codes = true # Show error codes in error messages
```These configurations help maintain a clean, readable, and consistent codebase while ensuring compliance with specified coding standards.
## Continuous Integration
The project includes a GitHub Actions workflow (`.github/workflows/lint-code.yml`) to automatically lint code on every push or pull request.
Additionally, the project includes a GitHub Actions workflow (`.github/workflows/test-code.yml`) to automatically run tests on every push or pull request.
## License
This project is licensed under the MIT License. See the [LICENSE] file for details.
[`.github/workflows/requirements.txt` file]: .github/workflows/requirements.txt
[LICENSE]: LICENSE