From 965952aa37d99a372315bc7b7319712e9f8152f8 Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sat, 10 Jan 2026 05:12:03 +0100 Subject: [PATCH] Refactoring folders --- .dockerignore | 6 --- .pre-commit-config.yaml | 40 ------------------ CONTRIBUTING.md | 90 ++++++++++++++++++++++++++++++++++------- lint.sh | 21 ++++++++++ pyproject.toml | 47 +++++++++++++++++++++ 5 files changed, 144 insertions(+), 60 deletions(-) delete mode 100644 .dockerignore delete mode 100644 .pre-commit-config.yaml create mode 100755 lint.sh create mode 100644 pyproject.toml diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index a809789..0000000 --- a/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -.git -__pycache__ -*.pyc -tests -docs -exemples diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index eda0da9..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -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", - ] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 029a156..e348e91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,9 @@ This project enforces: - **Pylint** : ignoring W0511, W0718, R0801, R0903, R0914 - **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 @@ -79,35 +81,95 @@ See [.pre-commit-config.yaml](.pre-commit-config.yaml) for the exact configurati ```bash # Create & activate a virtual environment python3 -m venv .venv -source .venv/bin/activate # Linux/macOS -# .venv\Scripts\activate # Windows +source .venv/bin/activate -# Install dev dependencies -pip install -r aperisolve/requirements-dev.txt +# Install dependencies pip install -r aperisolve/requirements.txt +pip install -r aperisolve/requirements-dev.txt ``` ### 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 pre-commit install ``` -Check for issues: +You can also do a manual pass on all files before commiting: ```bash pre-commit run --all-files ``` -Format code: - -```bash -black . --line-length 100 -isort . --profile black -``` - > [!NOTE] > Continuous Integration (CI) runs all checks on every PR. Ensure your code passes before submitting. diff --git a/lint.sh b/lint.sh new file mode 100755 index 0000000..bda4320 --- /dev/null +++ b/lint.sh @@ -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!" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4714ae4 --- /dev/null +++ b/pyproject.toml @@ -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 +"""