diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 41f864737..575afbcb6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -70,8 +70,8 @@ jobs: vulture mcpgateway --min-confidence 80 - id: pylint - setup: pip install pylint pylint-pydantic - cmd: pylint mcpgateway --errors-only --fail-under=10 + setup: true + cmd: uv run pylint mcpgateway --fail-on E --fail-under=10 - id: interrogate setup: pip install interrogate @@ -131,6 +131,11 @@ jobs: with: python-version: "3.12" cache: pip + # ----------------------------------------------------------- + # Install uv + # ----------------------------------------------------------- + - name: โšกSet up uv + uses: astral-sh/setup-uv@v6 # ----------------------------------------------------------- # 2๏ธโƒฃ Install Project + Dev Dependencies diff --git a/.nvim.lua b/.nvim.lua index fa0749bdb..8e0049d39 100644 --- a/.nvim.lua +++ b/.nvim.lua @@ -1,25 +1,34 @@ - -- Set colorcolumn to 200 for Python files only vim.api.nvim_create_autocmd("FileType", { - pattern = "python", - callback = function() - vim.opt_local.colorcolumn = "200" - end, + pattern = "python", + callback = function() + vim.opt_local.colorcolumn = "200" + end, +}) + +-- Set up for line formatting .md files to a 120-character limit +vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + vim.opt_local.colorcolumn = "120" + vim.opt_local.textwidth = 120 + end, }) -- -- Project settings for ALE (Asynchronous Lint Engine) -- ALE is available at https://github.com/dense-analysis/ale +-- vim.g.ale_linters = { - make = {}, - python = { "mypy", "ruff" }, - markdown = { "markdownlint" }, + make = {}, + python = { "mypy", "ruff", "flake8", "pylint" }, + markdown = { "markdownlint" }, } vim.g.ale_python_auto_uv = 1 -vim.g.ale_python_mypy_options='--no-pretty' -vim.g.ale_python_ruff_options = '--extend-select I' -vim.g.ale_markdown_markdownlint_executable = 'markdownlint-cli2' +vim.g.ale_python_mypy_options = "--no-pretty" +vim.g.ale_python_ruff_options = "--extend-select I" +vim.g.ale_markdown_markdownlint_executable = "markdownlint-cli2" vim.g.ale_fixers = { python = { "ruff", "black" }, diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a62e1a3ff..5073d51ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ # report issues (linters). Modified files will need to be staged again. # ----------------------------------------------------------------------------- -exclude: '(^|/)(\.pre-commit-config\.yaml|normalize_special_characters\.py|test_input_validation\.py|ai_artifacts_normalizer\.py)$|(^|/)mcp-servers/templates/|(^|/)tests/load/|.*\.(jinja|j2)$' # ignore these files, all templates, load tests, and jinja files +exclude: '(^|/)(\.pre-commit-.*\.yaml|normalize_special_characters\.py|test_input_validation\.py|ai_artifacts_normalizer\.py)$|(^|/)mcp-servers/templates/|(^|/)tests/load/|.*\.(jinja|j2)$' # ignore these files, all templates, load tests, and jinja files repos: # ----------------------------------------------------------------------------- @@ -190,11 +190,6 @@ repos: description: Removes UTF-8 byte order marker. types: [text] - - id: fix-encoding-pragma - name: ๐Ÿงน Fix Python Encoding Pragma - description: "Adds # -*- coding: utf-8 -*- to the top of python files." - types: [python] - - id: mixed-line-ending name: ๐Ÿงน Mixed Line Ending description: Replaces or checks mixed line ending. @@ -371,12 +366,12 @@ repos: exclude: ^tests/(.*/)?(pages|helpers|fuzzers|scripts|fixtures|migration|utils|manual|async|load)/.*\.py$ args: [--pytest-test-first] # `test_.*\.py` - # - repo: https://github.com/pycqa/flake8 - # rev: 7.2.0 - # hooks: - # - id: flake8 - # name: ๐Ÿ Flake8 - Python Linter - # description: Tool for style guide enforcement. + - repo: https://github.com/pycqa/flake8 + rev: 7.2.0 + hooks: + - id: flake8 + name: ๐Ÿ Flake8 - Python Linter + description: Tool for style guide enforcement. # - repo: https://github.com/pycqa/bandit # rev: 1.8.3 @@ -418,13 +413,13 @@ repos: # types_or: [ python, pyi ] # files: ^mcpgateway/ - # - repo: https://github.com/psf/black - # rev: 25.1.0 - # hooks: - # - id: black - # name: ๐Ÿ Black - Python Code Formatter - # description: The uncompromising Python code formatter. - # language_version: python3 + - repo: https://github.com/psf/black + rev: 25.1.0 + hooks: + - id: black + name: ๐Ÿ Black - Python Code Formatter + description: The uncompromising Python code formatter. + language_version: python3 # - repo: https://github.com/pycqa/isort # rev: 6.0.1 diff --git a/.pre-commit-lite.yaml b/.pre-commit-lite.yaml new file mode 100644 index 000000000..3d494333b --- /dev/null +++ b/.pre-commit-lite.yaml @@ -0,0 +1,539 @@ +# ----------------------------------------------------------------------------- +# ๐Ÿ› ๏ธ Pre-commit Configuration +# ----------------------------------------------------------------------------- +# This configuration file sets up various pre-commit hooks to enforce code quality, +# security, and formatting standards before commits are made. +# +# Installation: +# pip install --user --upgrade pre-commit +# pre-commit install +# pre-commit run --all-files +# Update: +# pre-commit autoupdate +# +# To skip pre-commit checks: +# git commit -m "Your message" --no-verify +# +# NOTE: Some hooks modify files automatically (formatters), while others only +# report issues (linters). Modified files will need to be staged again. +# ----------------------------------------------------------------------------- + +exclude: '(^|/)(\.pre-commit-.*\.yaml|normalize_special_characters\.py|test_input_validation\.py|ai_artifacts_normalizer\.py)$|(^|/)mcp-servers/templates/|(^|/)tests/load/|.*\.(jinja|j2)$' # ignore these files, all templates, load tests, and jinja files + +repos: + # ----------------------------------------------------------------------------- + # ๐Ÿ” Security and Secret Detection Hooks + # ----------------------------------------------------------------------------- + - repo: https://github.com/gitleaks/gitleaks + rev: v8.27.2 + hooks: + - id: gitleaks + name: ๐Ÿ” Gitleaks - Detect hardcoded secrets + description: Scans for hardcoded secrets like API keys and passwords. + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + # - id: detect-aws-credentials + # name: ๐Ÿ” Detect AWS Credentials + # description: Detects *your* aws credentials from the aws cli credentials file. + # types: [text] + + - id: detect-private-key + name: ๐Ÿ” Detect Private Key + description: Detects the presence of private keys. + types: [text] + + # - repo: https://github.com/Yelp/detect-secrets + # rev: v1.5.0 + # hooks: + # - id: detect-secrets + # name: ๐Ÿ” Detect Secrets + # description: Detects secrets within a repository. + # args: ['--baseline', '.secrets.baseline'] + + # ----------------------------------------------------------------------------- + # โŒ Forbid Specific AI / LLM Patterns + # ----------------------------------------------------------------------------- + # Local hooks that block the most common "AI artefacts" before they enter + # the repository - including: + # + # - `:contentReference` + # - `[oaicite:??]` or filecite (e.g. `[oaicite:??12345]`) + # - source=chatgpt.com + # - Stock phrases such as + # - "As an AI language model" + # - "I am an AI developed by" + # - "This response was generated by" + # - "In conclusion," / "To summarize," / "It is important to note that" + # - "Remember that" / "Keep in mind that" + # - Placeholder citations like `(Author, 2023)` and `(Source: ...)` + # - Any code-fence of **four or more** consecutive back-ticks: ```` , ``````, ... + # ----------------------------------------------------------------------------- + - repo: local + hooks: + - id: forbid-content-reference + name: โŒ Forbid :contentReference + description: Prevents :contentReference patterns from being committed. + entry: ':contentReference' + language: pygrep + types: [text] + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + - id: forbid-oai-citations + name: โŒ Forbid OpenAI Citations + description: Prevents [oaicite:??digits] patterns from being committed. + entry: '\[oaicite:\?\?\d+\]' + language: pygrep + types: [text] + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + - id: forbid-ai-stock-phrases + name: โŒ Forbid AI Stock Phrases + description: Prevents common AI-generated phrases from being committed. + entry: '(?i)(brevity|source=chatgpt.com|turn0search0|filecite|as an ai language model|i am an ai developed by|this response was generated by|i don''t have real-time information|i don''t have access to real-time|i can''t browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i''m not able to access|i don''t have the ability to)' + language: pygrep + types: [text] + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + - id: forbid-placeholder-citations + name: โŒ Forbid Placeholder Citations + description: Prevents placeholder citations like (Author, 2023) from being committed. + entry: '\([A-Z][a-z]+,?\s+\d{4}\)' + language: pygrep + types: [text] + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + - id: forbid-source-placeholders + name: โŒ Forbid Source Placeholders + description: Prevents (Source:...) placeholders from being committed. + entry: '(?i)\(source:' + language: pygrep + types: [text] + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + - id: forbid-malformed-code-fences + name: โŒ Forbid Malformed Code Fences + description: Prevents code fences with 4+ backticks from being committed. + entry: '````+' + language: pygrep + types: [text] + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + - id: warn-ai-transitions + name: โš ๏ธ Warn AI Transition Phrases + description: Warns about common AI transition phrases (non-blocking). + entry: '(?i)(brevity|in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it''s worth noting that|please note that)' + language: pygrep + types: [text] + verbose: true + exclude: ^\.pre-commit-config\.yaml$ + stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual] + + + # ----------------------------------------------------------------------------- + # ๐Ÿ”ค Unicode Text Normalization (via texthooks) + # ----------------------------------------------------------------------------- + # A collection of hooks to clean up problematic Unicode characters: + # + # ๐Ÿ“ fix-smartquotes: Converts curly quotes (" " ' ') to standard ASCII quotes. + # ๐Ÿ”ก fix-ligatures: Replaces typographic ligatures (fi, ff) with ASCII equivalents. + # โฃ fix-spaces: Normalizes non-breaking and exotic spaces to regular spaces. + # ๐Ÿšซ forbid-bidi-controls: Prevents Unicode BiDi control characters used to + # obscure code logic or directionality. + # + # These prevent copy-paste artifacts, invisible formatting errors, and + # encoding bugs from creeping into the codebase. + # ----------------------------------------------------------------------------- + - repo: https://github.com/sirosen/texthooks + rev: 0.6.8 + hooks: + - id: fix-smartquotes + name: ๐Ÿ“ Normalize Smart Quotes + description: Replaces smart/curly quotes with standard ASCII quotes. + - id: fix-ligatures + name: ๐Ÿ”ก Normalize Ligatures + description: Replaces typographic ligatures with standard characters. + - id: fix-spaces + name: โฃ Normalize Unicode Spaces + description: Replaces non-breaking or exotic space characters with regular spaces. + - id: forbid-bidi-controls + name: ๐Ÿšซ Forbid BiDi Unicode Controls + description: Prevents bidirectional control characters that can obscure code meaning. + + # ----------------------------------------------------------------------------- + # ๐Ÿงน Formatting Hooks (MODIFIES FILES) + # ----------------------------------------------------------------------------- + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: end-of-file-fixer + name: ๐Ÿงน Fix End of Files + description: Ensures that a file is either empty, or ends with one newline. + types: [text] + stages: [pre-commit, pre-push, manual] + + - id: trailing-whitespace + name: ๐Ÿงน Trim Trailing Whitespace + description: Trims trailing whitespace. + types: [text] + stages: [pre-commit, pre-push, manual] + + - id: fix-byte-order-marker + name: ๐Ÿงน Fix UTF-8 Byte Order Marker + description: Removes UTF-8 byte order marker. + types: [text] + + - id: fix-encoding-pragma + name: ๐Ÿงน Fix Python Encoding Pragma + description: "Adds # -*- coding: utf-8 -*- to the top of python files." + types: [python] + + - id: mixed-line-ending + name: ๐Ÿงน Mixed Line Ending + description: Replaces or checks mixed line ending. + types: [text, python] + args: [--fix=lf] + + - id: requirements-txt-fixer + name: ๐Ÿงน Fix requirements.txt + description: Sorts entries in requirements.txt. + files: (requirements|constraints).*\.txt$ + + - id: file-contents-sorter + name: ๐Ÿงน File Contents Sorter + description: Sorts the lines in specified files (defaults to alphabetical). + language: python + files: "^$" + + - id: sort-simple-yaml + name: ๐Ÿงน Sort Simple YAML Files + description: Sorts simple YAML files which consist only of top-level keys. + files: "^$" + + # Optional: Uncomment to enable Prettier formatting + # - repo: https://github.com/pre-commit/mirrors-prettier + # rev: v3.0.3 + # hooks: + # - id: prettier + # name: ๐Ÿงน Prettier - Code Formatter + # description: Formats JavaScript, TypeScript, CSS, HTML, JSON, Markdown, and more. + # types_or: [javascript, jsx, ts, tsx, css, less, scss, json, markdown, yaml] + + # ----------------------------------------------------------------------------- + # โœ… Code Quality and Validation Hooks (LINTING ONLY) + # ----------------------------------------------------------------------------- + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + name: โœ… Check Added Large Files + description: Prevents committing large files. + stages: [pre-commit, pre-push, manual] + + - id: check-case-conflict + name: โœ… Check Case Conflicts + description: Checks for files that would conflict in case-insensitive filesystems. + + - id: check-merge-conflict + name: โœ… Check Merge Conflicts + description: Checks for files that contain merge conflict strings. + types: [text] + + - id: check-symlinks + name: โœ… Check Symlinks + description: Checks for symlinks which do not point to anything. + types: [symlink] + + - id: destroyed-symlinks + name: โœ… Detect Destroyed Symlinks + description: Detects symlinks which are changed to regular files. + types: [file] + + - id: check-executables-have-shebangs + name: โœ… Check Executables Have Shebangs + description: Ensures that (non-binary) executables have a shebang. + types: [text, executable] + stages: [pre-commit, pre-push, manual] + + - id: check-shebang-scripts-are-executable + name: โœ… Check Shebang Scripts Are Executable + description: Ensures that (non-binary) files with a shebang are executable. + types: [text] + stages: [pre-commit, pre-push, manual] + + - id: forbid-new-submodules + name: โœ… Forbid New Submodules + description: Prevents addition of new git submodules. + types: [directory] + + - id: forbid-submodules + name: โœ… Forbid Submodules + description: Forbids any submodules in the repository. + language: fail + entry: "submodules are not allowed in this repository:" + types: [directory] + + - id: check-vcs-permalinks + name: โœ… Check VCS Permalinks + description: Ensures that links to VCS websites are permalinks. + types: [text] + + # File Format Validation + - id: check-json + name: โœ… Check JSON + description: Checks JSON files for parseable syntax. + types: [json] + + - id: check-yaml + name: โœ… Check YAML + description: Checks YAML files for parseable syntax. + types: [yaml] + exclude: ^(docs/|charts/) + + - id: check-toml + name: โœ… Check TOML + description: Checks TOML files for parseable syntax. + types: [toml] + + - id: check-xml + name: โœ… Check XML + description: Checks XML files for parseable syntax. + types: [xml] + + - id: check-byte-order-marker + name: โœ… Check Byte Order Marker + description: Forbids files which have a UTF-8 byte-order marker. + types: [text] + + - repo: https://github.com/adrienverge/yamllint + rev: v1.37.1 + hooks: + - id: yamllint + name: โœ… YAMLlint - YAML Linter + description: A linter for YAML files. + args: [-c, .yamllint] + # Lint *.yml|*.yaml everywhere EXCEPT charts/** + files: ^.*\.(yml|yaml)$ + exclude: ^charts/ + + # - repo: https://github.com/igorshubovych/markdownlint-cli + # rev: v0.45.0 + # hooks: + # - id: markdownlint + # name: โœ… Markdownlint - Markdown Linter + # description: A tool to check markdown files and flag style issues. + + # ----------------------------------------------------------------------------- + # ๐Ÿ Python Code Quality Hooks (LINTING ONLY) + # ----------------------------------------------------------------------------- + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-ast + name: ๐Ÿ Check Python AST + description: Simply checks whether the files parse as valid python. + language: python + types: [python] + exclude: ^templates/ + + - id: check-builtin-literals + name: ๐Ÿ Check Builtin Literals + description: Requires literal syntax when initializing empty or zero Python builtin types. + language: python + types: [python] + exclude: ^templates/ + + - id: check-docstring-first + name: ๐Ÿ Check Docstring is First + description: Checks a common error of defining a docstring after code. + language: python + types: [python] + + - id: debug-statements + name: ๐Ÿ Debug Statements (Python) + description: Checks for debugger imports and py37+ `breakpoint()` calls. + types: [python] + language: python + exclude: ^templates/ + + - id: name-tests-test + name: ๐Ÿ Python Tests Naming + description: Verifies test files in tests/ directories start with `test_`. + language: python + files: (^|/)tests/.+\.py$ + exclude: ^tests/(.*/)?(pages|helpers|fuzzers|scripts|fixtures|migration|utils|manual|async|load)/.*\.py$ + args: [--pytest-test-first] # `test_.*\.py` + + # - repo: https://github.com/pycqa/flake8 + # rev: 7.2.0 + # hooks: + # - id: flake8 + # name: ๐Ÿ Flake8 - Python Linter + # description: Tool for style guide enforcement. + + # - repo: https://github.com/pycqa/bandit + # rev: 1.8.3 + # hooks: + # - id: bandit + # name: ๐Ÿ Bandit - Security Linter + # description: A tool designed to find common security issues in Python code. + # args: [--skip, "B101,B601"] + + # - repo: https://github.com/pre-commit/mirrors-mypy + # rev: v1.16.0 + # hooks: + # - id: mypy + # name: ๐Ÿ MyPy - Static Type Checker + # description: Optional static typing for Python. + # additional_dependencies: [types-all] + + # - repo: https://github.com/pycqa/pydocstyle + # rev: 6.3.0 + # hooks: + # - id: pydocstyle + # name: ๐Ÿ PyDocStyle - Docstring Checker + # description: A static analysis tool for checking compliance with Python docstring conventions. + + # ----------------------------------------------------------------------------- + # ๐Ÿ Python Formatting Hooks (MODIFIES FILES) + # ----------------------------------------------------------------------------- + # - repo: https://github.com/astral-sh/ruff-pre-commit + # # Ruff version. + # rev: v0.11.12 + # hooks: + # # Run the linter. + # - id: ruff-check + # types_or: [ python, pyi ] + # args: [ --fix ] + # files: ^mcpgateway/ + # Run the formatter. + # - id: ruff-format + # types_or: [ python, pyi ] + # files: ^mcpgateway/ + + # - repo: https://github.com/psf/black + # rev: 25.1.0 + # hooks: + # - id: black + # name: ๐Ÿ Black - Python Code Formatter + # description: The uncompromising Python code formatter. + # language_version: python3 + + # - repo: https://github.com/pycqa/isort + # rev: 6.0.1 + # hooks: + # - id: isort + # name: ๐Ÿ isort - Import Sorter + # description: A Python utility / library to sort imports. + # args: [--profile=black] + + # - repo: https://github.com/asottile/pyupgrade + # rev: v3.20.0 + # hooks: + # - id: pyupgrade + # name: ๐Ÿ PyUpgrade - Python Syntax Upgrader + # description: Automatically upgrade syntax for newer versions of the language. + # args: [--py38-plus] + + # Optional: Uncomment to enforce single quotes in Python + # - repo: https://github.com/pre-commit/pre-commit-hooks + # rev: v5.0.0 + # hooks: + # - id: double-quote-string-fixer + # name: ๐Ÿ Fix Double Quoted Strings + # description: Replaces double quoted strings with single quoted strings. + # types: [python] + + # ----------------------------------------------------------------------------- + # ๐ŸŒ Web Development Hooks (LINTING ONLY) + # ----------------------------------------------------------------------------- + # - repo: https://github.com/pre-commit/mirrors-eslint + # rev: v8.50.0 + # hooks: + # - id: eslint + # name: ๐ŸŒ ESLint - JavaScript/TypeScript Linter + # description: Find and fix problems in your JavaScript code. + # files: \.(js|jsx|ts|tsx)$ + # types: [file] + + # - repo: https://github.com/thibaudcolas/pre-commit-stylelint + # rev: v16.20.0 + # hooks: + # - id: stylelint + # name: ๐ŸŒ Stylelint - CSS Linter + # description: A mighty, modern linter that helps you avoid errors and enforce conventions in your styles. + # files: \.(css|scss|sass|less)$ + + # ----------------------------------------------------------------------------- + # ๐Ÿš€ Performance and Optimization Hooks (MODIFIES FILES) + # ----------------------------------------------------------------------------- + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-crlf + name: ๐Ÿš€ Remove CRLF + description: Replaces CRLF line endings by LF. + + - id: remove-tabs + name: ๐Ÿš€ Remove Tabs + description: Replaces tabs by whitespaces. + # exclude root-level Makefiles and any path ending in /Makefile or .mk or .jinja + exclude: '(^|/)Makefile$|(\.mk|\.jinja)$' + + # ----------------------------------------------------------------------------- + # ๐Ÿšซ Branch Protection Hooks + # ----------------------------------------------------------------------------- + # - repo: https://github.com/pre-commit/pre-commit-hooks + # rev: v5.0.0 + # hooks: + # - id: no-commit-to-branch + # name: ๐Ÿšซ Prevent Commits to Protected Branches + # description: Prevents commits to specified branches. + # pass_filenames: false + # always_run: true + # args: [--branch, main, --branch, master, --branch, develop] + + # ----------------------------------------------------------------------------- + # ๐Ÿ“ Documentation Hooks (MODIFIES FILES) + # ----------------------------------------------------------------------------- + # - repo: https://github.com/executablebooks/mdformat + # rev: 0.7.17 + # hooks: + # - id: mdformat + # name: ๐Ÿ“ MDFormat - Markdown Formatter + # description: An opinionated Markdown formatter. + # additional_dependencies: + # - mdformat-gfm + # - mdformat-tables + # - mdformat-black + + # ----------------------------------------------------------------------------- + # ๐Ÿงช DOCTEST VALIDATION + # ----------------------------------------------------------------------------- + # - repo: local + # hooks: + # - id: doctest + # name: ๐Ÿงช Doctest - Validate Documentation Examples + # description: Runs doctest on all Python modules to ensure documentation examples work. + # entry: python3 -m pytest --doctest-modules mcpgateway/ --tb=short + # language: system + # pass_filenames: false + # always_run: true + # types: [python] + + # ----------------------------------------------------------------------------- + # Interrogate + # ----------------------------------------------------------------------------- + - repo: https://github.com/econchick/interrogate + rev: 1.7.0 # or master if you're bold + hooks: + - id: interrogate + args: [--quiet, --fail-under=100] + files: ^mcpgateway/ diff --git a/Makefile b/Makefile index cf4192b26..34fe0495b 100644 --- a/Makefile +++ b/Makefile @@ -103,12 +103,27 @@ endef # ๐ŸŒฑ VIRTUAL ENVIRONMENT & INSTALLATION # ============================================================================= # help: ๐ŸŒฑ VIRTUAL ENVIRONMENT & INSTALLATION +# help: uv - Ensure uv is installed or install it if needed # help: venv - Create a fresh virtual environment with uv & friends # help: activate - Activate the virtual environment in the current shell # help: install - Install project into the venv # help: install-dev - Install project (incl. dev deps) into the venv # help: install-db - Install project (incl. postgres and redis) into venv # help: update - Update all installed deps inside the venv +.PHONY: uv +uv: + @if ! type uv >/dev/null 2>&1; then \ + echo "๐Ÿ”ง 'uv' not found - installing..."; \ + if type brew >/dev/null 2>&1; then \ + echo "๐Ÿบ Installing 'uv' via Homebrew..."; \ + brew install uv; \ + else \ + echo "๐Ÿ Installing 'uv' via local install script..."; \ + curl -LsSf https://astral.sh/uv/install.sh | sh ; \ + echo "๐Ÿ’ก Make sure to add 'uv' to your PATH if not done automatically."; \ + fi; \ + fi + .PHONY: venv venv: @rm -Rf "$(VENV_DIR)" @@ -428,7 +443,7 @@ test: @/bin/bash -c "source $(VENV_DIR)/bin/activate && \ export DATABASE_URL='sqlite:///:memory:' && \ export TEST_DATABASE_URL='sqlite:///:memory:' && \ - uv run pytest -n auto --maxfail=0 --disable-warnings -v --ignore=tests/fuzz" + uv run pytest -n auto --maxfail=0 -v --ignore=tests/fuzz" test-profile: @echo "๐Ÿงช Running tests with profiling (showing slowest tests)..." @@ -1010,8 +1025,9 @@ isort-check: flake8: ## ๐Ÿ flake8 checks @echo "๐Ÿ flake8 $(TARGET)..." && $(VENV_DIR)/bin/flake8 $(TARGET) -pylint: ## ๐Ÿ› pylint checks - @echo "๐Ÿ› pylint $(TARGET) (parallel)..." && $(VENV_DIR)/bin/pylint -j 8 $(TARGET) +pylint: uv ## ๐Ÿ› pylint checks + @echo "๐Ÿ› pylint $(TARGET) (parallel)..." + uv run pylint -j 0 --fail-on E --fail-under 10 $(TARGET) markdownlint: ## ๐Ÿ“– Markdown linting @# Install markdownlint-cli2 if not present @@ -1055,14 +1071,9 @@ pydocstyle: ## ๐Ÿ“š Docstring style pycodestyle: ## ๐Ÿ“ Simple PEP-8 checker @echo "๐Ÿ“ pycodestyle $(TARGET)..." && $(VENV_DIR)/bin/pycodestyle $(TARGET) --max-line-length=200 -pre-commit: ## ๐Ÿช„ Run pre-commit hooks +pre-commit: uv ## ๐Ÿช„ Run pre-commit tool @echo "๐Ÿช„ Running pre-commit hooks..." - @test -d "$(VENV_DIR)" || $(MAKE) venv install install-dev - @if [ ! -f "$(VENV_DIR)/bin/pre-commit" ]; then \ - echo "๐Ÿ“ฆ Installing pre-commit..."; \ - /bin/bash -c "source $(VENV_DIR)/bin/activate && python3 -m pip install --quiet pre-commit"; \ - fi - @/bin/bash -c "source $(VENV_DIR)/bin/activate && pre-commit run --all-files --show-diff-on-failure" + uv run pre-commit run --config .pre-commit-lite.yaml --all-files --show-diff-on-failure ruff: ## โšก Ruff lint + (eventually) format @echo "โšก ruff $(TARGET)..." && $(VENV_DIR)/bin/ruff check $(TARGET)