Py Quality Setup logo

Py Quality Setup

Community
l-mb
py-quality-setup

Configure ruff, mypy, and basedpyright for Python 3.13 projects. Use when setting up linters and type checkers in pyproject.toml and pyrightconfig.json.

Overview

Publisherl-mb
Repositorypython-refactoring-skills
Skill namepy-quality-setup
Stars
57
Forks
1
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by l-mb on GitHub. Read the source before you install it.

Installation

Install the Py Quality Setup AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/l-mb/python-refactoring-skills/tree/main/skills/py-quality-setup
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/l-mb/python-refactoring-skills.git /tmp/python-refactoring-skills
mkdir -p .claude/skills
cp -r /tmp/python-refactoring-skills/skills/py-quality-setup .claude/skills/py-quality-setup
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Py Quality Setup in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Py Quality Setup on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Py Quality Setup is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Python Quality Tooling Setup

Configure comprehensive linting and type checking for Python 3.13 projects following Engineering Charter standards.

Objectives

  1. Configure ruff for linting and formatting
  2. Configure mypy for strict type checking
  3. Configure basedpyright for additional type analysis
  4. Ensure all tools target Python 3.13 or later
  5. Add tools to dev dependencies

Required Tools

Add to [dependency-groups] dev: "ruff", "mypy", "basedpyright", "pytest", "pytest-cov"

  • ruff: Fast linter and formatter (Rust-based, replaces black, isort, flake8)
  • mypy: Standard Python type checker
  • basedpyright: Enhanced Pyright fork with additional type analysis

Required Configuration Files

pyproject.toml (Canonical Reference)

This skill provides the canonical pyproject.toml configuration for all quality tools. Other skills reference this configuration.

Must include these sections:

toml
[project]
requires-python = ">=3.13"

[dependency-groups]
dev = [
    "pytest>=8.0",
    "pytest-cov>=4.0",
    "ruff>=0.8.0",
    "mypy>=1.0",
    "basedpyright>=1.0",
    "pre-commit>=3.0",
    # Analysis tools (add as needed for py-* skills):
    # "radon", "vulture", "pylint", "bandit", "lizard",
    # "mutmut", "wily", "xenon", "pyupgrade", "coverage",
]

[tool.ruff]
line-length = 100  # or 140 for larger projects
target-version = "py313"
src = ["src"]  # adjust to your source directory

[tool.ruff.lint]
select = [
    "E",   # pycodestyle errors
    "W",   # pycodestyle warnings
    "F",   # pyflakes
    "I",   # isort
    "N",   # pep8-naming
    "UP",  # pyupgrade
    "B",   # flake8-bugbear
    "C4",  # flake8-comprehensions
    "SIM", # flake8-simplify
]
ignore = []

[tool.mypy]
python_version = "3.13"
strict = true
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
check_untyped_defs = true

# Add overrides for third-party packages without stubs
# [[tool.mypy.overrides]]
# module = "package_name"
# ignore_missing_imports = true

[tool.basedpyright]
pythonVersion = "3.13"
typeCheckingMode = "standard"  # or "recommended" for stricter
reportMissingTypeStubs = false
reportUnknownMemberType = false
reportUnknownArgumentType = false
reportUnknownVariableType = false

pyrightconfig.json (optional, for multi-package projects)

A.When using pyrightconfig.json for multi-package projects, REMOVE the tool.basedpyright section from pyproject.toml

json
{
  "include": ["src"],
  "exclude": ["**/node_modules", "**/__pycache__", "**/.*", "venv", ".venv"],
  "pythonVersion": "3.13",
  "typeCheckingMode": "recommended",
  "reportMissingImports": "error",
  "reportMissingTypeStubs": false,
  "reportUnknownMemberType": false,
  "reportUnknownVariableType": false,
  "reportUnknownArgumentType": false,
  "reportMissingParameterType": true,
  "reportUnusedVariable": true,
  "reportImplicitStringConcatenation": true,
  "reportUnnecessaryTypeIgnoreComment": true
}

Setup Workflow

  1. Check existing configuration

    • Read pyproject.toml
    • Check if dev dependencies exist
    • Verify Python version requirement
  2. Update or create configuration

    • Add dev dependencies if missing
    • Add/update [tool.ruff] section
    • Add/update [tool.mypy] section
    • Add/update [tool.basedpyright] section
    • Create pyrightconfig.json if needed (multi-package projects)
  3. Install tools in venv

    bash
    # Using uv (recommended):
    uv sync                      # Creates venv and installs dev group automatically
    
    # Or manually:
    uv venv
    source .venv/bin/activate
    uv sync --group dev
    
    # Fallback if uv not available:
    # python -m venv venv
    # source venv/bin/activate
    # pip install -e ".[dev]"
  4. Verify installation

    bash
    which ruff mypy basedpyright
    ruff --version
    mypy --version
    basedpyright --version
  5. Run initial checks

    bash
    ruff check .
    mypy .
    basedpyright .
  6. Configure Claude Code permissions

    Write .claude/settings.local.json so all py-* skills can run without permission prompts. If the file already exists, merge new entries into the existing allow list without removing user entries.

    json
    {
      "permissions": {
        "allow": [
          "Bash(ruff *)",
          "Bash(mypy *)",
          "Bash(basedpyright *)",
          "Bash(pytest *)",
          "Bash(vulture *)",
          "Bash(pylint *)",
          "Bash(radon *)",
          "Bash(lizard *)",
          "Bash(wily *)",
          "Bash(bandit *)",
          "Bash(mutmut *)",
          "Bash(pyupgrade *)",
          "Bash(scc *)",
          "Bash(pre-commit *)",
          "Bash(uv *)",
          "Bash(pip *)",
          "Bash(python3 *)",
          "Bash(python *)",
          "Bash(source *)",
          "Bash(which *)",
          "Bash(mkdir *)",
          "Bash(chmod *)",
          "Bash(ls *)",
          "Bash(ln *)",
          "Bash(git add *)",
          "Bash(git diff *)",
          "Bash(git status *)",
          "Bash(git log *)",
          "Bash(git ls-files *)",
          "Bash(git checkout *)",
          "Bash(git branch *)",
          "Bash(git commit *)"
        ],
        "deny": []
      }
    }

    Merge logic: Read existing file, parse JSON, take union of allow lists, write back. Create .claude/ directory if needed.

  7. Install Stop hook lint gate

    Symlink the lint gate script so Claude Code runs the full lint suite (ruff, mypy, basedpyright) on modified files before returning to the user. If any linter reports errors, Claude is blocked from stopping and must fix them first.

    bash
    mkdir -p ~/.claude/hooks
    ln -sf ~/.claude/skills/py-git-hooks/lint-gate.py ~/.claude/hooks/lint-gate.py

    Configure the Stop hook in ~/.claude/settings.json (merge into existing hooks if present):

    json
    {
      "hooks": {
        "Stop": [
          {
            "hooks": [
              {
                "type": "command",
                "command": "python3 ~/.claude/hooks/lint-gate.py"
              }
            ]
          }
        ]
      }
    }
  8. Configure git hooks (if requested)

    • Set up pre-commit hook to run linters
    • See py-git-hooks skill

Tool-Specific Notes

Ruff

  • Fastest Python linter (Rust-based)
  • Replaces: black, isort, flake8, and many plugins
  • Auto-fix: ruff check --fix .
  • Format: ruff format .

Mypy

  • Standard Python type checker
  • Strict mode catches most type errors
  • Use # type: ignore[error-code] sparingly
  • Add overrides for packages without stubs

Basedpyright

  • Fork of Pyright with more features
  • Catches some errors mypy misses
  • More configurable than Pyright
  • Works well alongside mypy

Common Adjustments

Monorepo/multi-package:

  • Use pyrightconfig.json with extraPaths
  • Set namespace_packages = true in mypy

Legacy codebase:

  • Start with less strict mypy (strict = false)
  • Gradually enable strict checks
  • Use mypy overrides per module

Third-party packages without stubs:

toml
[[tool.mypy.overrides]]
module = "package_name"
ignore_missing_imports = true

Verification Checklist

  • pyproject.toml has requires-python = ">=3.13"
  • dev dependencies include ruff, mypy, basedpyright
  • [tool.ruff] configured with target-version = "py313"
  • [tool.mypy] configured with python_version = "3.13"
  • [tool.basedpyright] configured with pythonVersion = "3.13"
  • All tools installed in venv
  • ruff check passes (or only expected errors)
  • mypy . passes (or only expected errors)
  • basedpyright . passes (or only expected errors)
  • .claude/settings.local.json exists with permissions for all quality tools
  • ~/.claude/hooks/lint-gate.py symlinked and Stop hook configured in ~/.claude/settings.json

Examples

Example: New project setup

1. Create venv: uv venv && source .venv/bin/activate
2. Create pyproject.toml with [project], [tool.ruff], [tool.mypy], [tool.basedpyright]
3. Install: uv pip install -e ".[dev]"
4. Verify: ruff --version && mypy --version && basedpyright --version
5. Run initial checks: ruff check . && mypy . && basedpyright .
6. Fix issues or add ignores for false positives

Example: Add quality tools to existing project

1. Activate venv: source .venv/bin/activate
2. Update pyproject.toml:
   - Add ruff, mypy, basedpyright to [project.optional-dependencies] dev
   - Add [tool.ruff], [tool.mypy], [tool.basedpyright] sections
3. Install: uv pip install -e ".[dev]"
4. Run checks: ruff check . (expect many errors initially)
5. Auto-fix: ruff check --fix . && ruff format .
6. Run type checkers: mypy . && basedpyright .
7. Add [[tool.mypy.overrides]] for third-party packages without stubs
8. Iterate until all checks pass

Example: Legacy codebase gradual adoption

1. Start with minimal ruff rules: select = ["E", "F"]
2. Start mypy non-strict: strict = false
3. Fix errors incrementally, expand rules over time
4. Add per-module mypy overrides for problematic modules
5. Eventually enable strict mode project-wide

Related Skills

  • Foundation: This skill is the foundation for all other skills
  • Next steps: py-git-hooks (automate enforcement of configured tools)
  • See also: py-modernize (for uv migration and syntax upgrades)

Frequently asked questions

What does the Py Quality Setup AI skill do?

Configure ruff, mypy, and basedpyright for Python 3.13 projects. Use when setting up linters and type checkers in pyproject.toml and pyrightconfig.json.

Why use Py Quality Setup on TypingMind?

Because you install it once and use it with any model. Py Quality Setup is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Py Quality Setup in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/l-mb/python-refactoring-skills/tree/main/skills/py-quality-setup. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Py Quality Setup?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Py Quality Setup?

As many as you like. As long as a model supports skills, you can use Py Quality Setup with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Py Quality Setup AI skill free?

Yes. It is published on GitHub by l-mb under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇