Refactoring folders
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
.git
|
|
||||||
__pycache__
|
|
||||||
*.pyc
|
|
||||||
tests
|
|
||||||
docs
|
|
||||||
exemples
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
repos:
|
|
||||||
- repo: https://github.com/psf/black
|
|
||||||
rev: 25.12.0
|
|
||||||
hooks:
|
|
||||||
- id: black
|
|
||||||
args: ['--line-length', '100']
|
|
||||||
- repo: https://github.com/pycqa/isort
|
|
||||||
rev: 7.0.0
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
args: ['--profile', 'black']
|
|
||||||
- repo: https://github.com/PyCQA/flake8
|
|
||||||
rev: 7.3.0
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
args: ['--extend-ignore','E203,E501,W503']
|
|
||||||
- repo: https://github.com/pylint-dev/pylint
|
|
||||||
rev: v4.0.4
|
|
||||||
hooks:
|
|
||||||
- id: pylint
|
|
||||||
args: ['--disable', 'W0511,W0718,R0801,R0903,R0914']
|
|
||||||
language: system
|
|
||||||
- repo: local
|
|
||||||
hooks:
|
|
||||||
- id: mypy
|
|
||||||
name: mypy
|
|
||||||
entry: mypy
|
|
||||||
types: [python]
|
|
||||||
language: system
|
|
||||||
pass_filenames: true
|
|
||||||
args:
|
|
||||||
[
|
|
||||||
"--disallow-any-generics",
|
|
||||||
"--disallow-untyped-def",
|
|
||||||
"--follow-imports",
|
|
||||||
"skip",
|
|
||||||
"--ignore-missing-imports",
|
|
||||||
"--disable-error-code",
|
|
||||||
"unused-awaitable",
|
|
||||||
]
|
|
||||||
+76
-14
@@ -69,7 +69,9 @@ This project enforces:
|
|||||||
- **Pylint** : ignoring W0511, W0718, R0801, R0903, R0914
|
- **Pylint** : ignoring W0511, W0718, R0801, R0903, R0914
|
||||||
- **Mypy** : ignoring unused-awaitable
|
- **Mypy** : ignoring unused-awaitable
|
||||||
|
|
||||||
See [.pre-commit-config.yaml](.pre-commit-config.yaml) for the exact configuration.
|
> [!TIP]
|
||||||
|
> All tool configurations (Black, Isort, Flake8, Mypy, Pylint) are centralized in pyproject.toml.
|
||||||
|
> You can run each tool directly and it will automatically pick up the configuration.
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
@@ -79,35 +81,95 @@ See [.pre-commit-config.yaml](.pre-commit-config.yaml) for the exact configurati
|
|||||||
```bash
|
```bash
|
||||||
# Create & activate a virtual environment
|
# Create & activate a virtual environment
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
source .venv/bin/activate # Linux/macOS
|
source .venv/bin/activate
|
||||||
# .venv\Scripts\activate # Windows
|
|
||||||
|
|
||||||
# Install dev dependencies
|
# Install dependencies
|
||||||
pip install -r aperisolve/requirements-dev.txt
|
|
||||||
pip install -r aperisolve/requirements.txt
|
pip install -r aperisolve/requirements.txt
|
||||||
|
pip install -r aperisolve/requirements-dev.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running Tools Manually
|
### Running Tools Manually
|
||||||
|
|
||||||
Install pre-commit hooks to automatically check your code before commits:
|
**Option 1 - Bash script (no pre-commit file needed)**
|
||||||
|
|
||||||
|
Run this script [lint.sh](lint.sh) at the project root folder.
|
||||||
|
|
||||||
|
```
|
||||||
|
🖤 Running Black...
|
||||||
|
All done! ✨ 🍰 ✨
|
||||||
|
25 files left unchanged.
|
||||||
|
📦 Running Isort...
|
||||||
|
Skipped 2 files
|
||||||
|
🐍 Running Flake8...
|
||||||
|
🔍 Running Mypy...
|
||||||
|
Success: no issues found in 25 source files
|
||||||
|
⚡ Running Pylint...
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
Your code has been rated at 10.00/10
|
||||||
|
|
||||||
|
✅ All checks passed!
|
||||||
|
```
|
||||||
|
|
||||||
|
**Option 2 - Pre-Commit hook**
|
||||||
|
|
||||||
|
Create a pre-commit hooks file [.pre-commit-config.yaml](#) at the project root folder.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 25.12.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
args: ['--line-length', '100']
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 7.0.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
args: ['--profile', 'black']
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 7.3.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
args: ['--extend-ignore','E203,E501,W503']
|
||||||
|
- repo: https://github.com/pylint-dev/pylint
|
||||||
|
rev: v4.0.4
|
||||||
|
hooks:
|
||||||
|
- id: pylint
|
||||||
|
args: ['--disable', 'W0511,W0718,R0801,R0903,R0914']
|
||||||
|
language: system
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
name: mypy
|
||||||
|
entry: mypy
|
||||||
|
types: [python]
|
||||||
|
language: system
|
||||||
|
pass_filenames: true
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
"--disallow-any-generics",
|
||||||
|
"--disallow-untyped-def",
|
||||||
|
"--follow-imports",
|
||||||
|
"skip",
|
||||||
|
"--ignore-missing-imports",
|
||||||
|
"--disable-error-code",
|
||||||
|
"unused-awaitable",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run the following command so each staged files will be checked while commited.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pre-commit install
|
pre-commit install
|
||||||
```
|
```
|
||||||
|
|
||||||
Check for issues:
|
You can also do a manual pass on all files before commiting:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pre-commit run --all-files
|
pre-commit run --all-files
|
||||||
```
|
```
|
||||||
|
|
||||||
Format code:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
black . --line-length 100
|
|
||||||
isort . --profile black
|
|
||||||
```
|
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Continuous Integration (CI) runs all checks on every PR. Ensure your code passes before submitting.
|
> Continuous Integration (CI) runs all checks on every PR. Ensure your code passes before submitting.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# lint.sh - Run all formatters, linters, and type checks according to pyproject.toml
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "🖤 Running Black..."
|
||||||
|
black .
|
||||||
|
|
||||||
|
echo "📦 Running Isort..."
|
||||||
|
isort .
|
||||||
|
|
||||||
|
echo "🐍 Running Flake8..."
|
||||||
|
flake8 --max-line-length 100 --extend-ignore=E203,E501,W503 .
|
||||||
|
|
||||||
|
echo "🔍 Running Mypy..."
|
||||||
|
mypy .
|
||||||
|
|
||||||
|
echo "⚡ Running Pylint..."
|
||||||
|
pylint aperisolve/
|
||||||
|
|
||||||
|
echo "✅ All checks passed!"
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# Minimal Python project configuration for linters and type checkers.
|
||||||
|
# This file centralizes config for black, isort, flake8, mypy, pylint.
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "aperisolve"
|
||||||
|
version = "3.1.1"
|
||||||
|
description = "Open-source steganalysis web platform for automated image analysis and steganography detection"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
license = {text = "MIT"}
|
||||||
|
authors = [
|
||||||
|
{name = "Zeecka"}
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 100
|
||||||
|
target-version = ["py312"]
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
|
||||||
|
[tool.flake8]
|
||||||
|
extend-ignore = ["E203", "E501", "W503"]
|
||||||
|
max-line-length = 100
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
disallow_any_generics = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
follow_imports = "skip"
|
||||||
|
ignore_missing_imports = true
|
||||||
|
disable_error_code = ["unused-awaitable"]
|
||||||
|
|
||||||
|
[tool.pylint]
|
||||||
|
disable = ["W0511", "W0718", "R0801", "R0903", "R0914"]
|
||||||
|
|
||||||
|
[tool.pre-commit]
|
||||||
|
skip = true
|
||||||
|
|
||||||
|
[tool.doc]
|
||||||
|
description = """
|
||||||
|
Linting and type checking configuration for this project.
|
||||||
|
- Black: code formatting
|
||||||
|
- Isort: import sorting
|
||||||
|
- Flake8: code style
|
||||||
|
- Mypy: static typing
|
||||||
|
- Pylint: code quality
|
||||||
|
"""
|
||||||
Reference in New Issue
Block a user