From aa38de5a34972f9f8adc7a52d3dd34385b1e90e9 Mon Sep 17 00:00:00 2001 From: Aditya <97450298+1234-ad@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:09:37 +0530 Subject: [PATCH 1/2] chore: add pre-commit hooks for code quality enforcement Add comprehensive pre-commit configuration to enforce code quality standards: - Black for consistent code formatting (100 char line length) - isort for import organization - flake8 for linting and style checks - bandit for security vulnerability scanning - mypy for static type checking - Standard file checks (trailing whitespace, EOF, YAML/JSON validation) - pydocstyle for docstring conventions (Google style) Benefits: - Catches issues before commit - Ensures consistent code style across contributors - Reduces review time by automating style checks - Improves code security with bandit scans Setup: Run `pip install pre-commit && pre-commit install` --- .pre-commit-config.yaml | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a17ea64 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,61 @@ +repos: + # Python code formatting with black + - repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + language_version: python3.13 + args: ['--line-length=100'] + + # Import sorting with isort + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + args: ['--profile', 'black', '--line-length', '100'] + + # Linting with flake8 + - repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + args: ['--max-line-length=100', '--extend-ignore=E203,W503'] + + # Security checks with bandit + - repo: https://github.com/PyCQA/bandit + rev: 1.7.6 + hooks: + - id: bandit + args: ['-c', 'pyproject.toml'] + additional_dependencies: ['bandit[toml]'] + + # Type checking with mypy + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + additional_dependencies: [types-all] + args: ['--ignore-missing-imports', '--no-strict-optional'] + + # General file checks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + args: ['--maxkb=1000'] + - id: check-json + - id: check-toml + - id: check-merge-conflict + - id: debug-statements + - id: mixed-line-ending + + # Docstring checks + - repo: https://github.com/PyCQA/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + args: ['--convention=google'] + exclude: 'test_.*\.py$' From 0fe7f6dba9e8e3b65e43f6238265eed5f18bb577 Mon Sep 17 00:00:00 2001 From: Aditya <97450298+1234-ad@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:09:47 +0530 Subject: [PATCH 2/2] chore: add pyproject.toml for tool configuration Add centralized configuration for Python development tools: - Black: 100 char line length, Python 3.13 target - isort: Black-compatible profile with trailing commas - bandit: Security scanning with test exclusions - mypy: Type checking configuration - pydocstyle: Google-style docstring conventions This provides consistent tool behavior across all contributors. --- pyproject.toml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..569d2a6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,41 @@ +[tool.black] +line-length = 100 +target-version = ['py313'] +include = '\.pyi?$' +extend-exclude = ''' +/( + # directories + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | build + | dist +)/ +''' + +[tool.isort] +profile = "black" +line_length = 100 +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +ensure_newline_before_comments = true + +[tool.bandit] +exclude_dirs = ["tests", "test"] +skips = ["B101", "B601"] + +[tool.mypy] +python_version = "3.13" +warn_return_any = true +warn_unused_configs = true +disallow_untyped_defs = false +ignore_missing_imports = true + +[tool.pydocstyle] +convention = "google" +add_ignore = ["D100", "D104"]