Skip to content

Setting up the environment

All development for this library happens in the pyt3client repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package:

# Clone the repository
git clone https://github.com/phil65/pyt3client.git
cd pyt3client

Build system

Uv is used as the build system.

pip install uv

More information

Tools

PyRight

PyRight is used for type checking. You can find the configuration in the pyproject.toml file.

pyright --help
Config
venvPath = "."
venv = ".venv"
pythonVersion = "3.13"
pythonPlatform = "All"
typeCheckingMode = "basic"
deprecateTypingAliases = true
reportMissingTypeStubs = false
reportUnusedCallResult = false
reportUnknownVariableType = false
reportAny = false
reportImplicitOverride = false
reportUnusedFunction = false
reportImplicitStringConcatenation = false
reportIgnoreCommentWithoutRule = false
reportUnannotatedClassAttribute = false
reportSelfClsParameterName = false
reportPrivateImportUsage = false
Installing PyRight

To install pyright:

pip install pyright
More information

Coverage

Coverage is used to monitor test coverage.

coverage run some_module.py
Config
[report]
exclude_lines = [
    "pragma: no cover",
    "if TYPE_CHECKING:",
    "@overload",
    "except ImportError",
    "if __name__ == \"__main__\":",
]
Installing Coverage

To install coverage:

pip install coverage
More information

Ruff

Ruff is used as a linter. You can find the configuration in the pyproject.toml file.

ruff --help
Config
line-length = 100
extend-exclude = [
    "docs",
]
target-version = "py313"

[lint]
future-annotations = true
select = [
    "A",
    "B",
    "BLE",
    "C",
    "C4",
    "COM",
    "D",
    "E",
    "EM",
    "EXE",
    "F",
    "FA",
    "FLY",
    "G",
    "I",
    "ICN",
    "INP",
    "INT",
    "ISC",
    "N",
    "PERF",
    "PIE",
    "PLE",
    "PLC",
    "PLR",
    "PT",
    "PTH",
    "PYI",
    "Q",
    "RET",
    "RSE",
    "RUF",
    "SIM",
    "SLF",
    "SLOT",
    "T10",
    "TC",
    "TID",
    "TRY",
    "UP",
    "W",
    "YTT",
]
ignore = [
    "C408",
    "B905",
    "C901",
    "COM812",
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D106",
    "D107",
    "D203",
    "D204",
    "D213",
    "D215",
    "D400",
    "D401",
    "D404",
    "D406",
    "D407",
    "D408",
    "D409",
    "D413",
    "EM101",
    "EM102",
    "ISC001",
    "PLC0415",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "SLF001",
    "TRY003",
    "TC006",
]

[lint.flake8-quotes]
docstring-quotes = "double"

[lint.flake8-type-checking]
runtime-evaluated-base-classes = [
    "pydantic.BaseModel",
    "sqlalchemy.orm.DeclarativeBase",
    "schemez.Schema",
    "sqlmodel.SQLModel",
]
runtime-evaluated-decorators = [
    "pydantic.validate_call",
    "fastapi.FastAPI.get",
    "fastapi.FastAPI.post",
    "fastmcp.FastMCP.tool",
    "typer.Typer.command",
]

[lint.isort]
lines-after-imports = 2
force-sort-within-sections = true
combine-as-imports = true

[lint.mccabe]
max-complexity = 15

[lint.per-file-ignores]
"__init__.py" = [
    "E402",
    "I001",
]
"scripts/*" = [
    "INP001",
]
"*tests/*" = [
    "D100",
    "PLR2004",
]
"src/pyt3client/cli/app.py" = [
    "PLR0917",
]
"src/pyt3client/models/tools.py" = [
    "D",
    "E501",
    "N815",
    "RUF",
    "UP",
    "TC",
    "PIE790",
    "PYI051",
]

[format]
preview = true
Installing Ruff

To install ruff:

pip install ruff
More information

MkDocs

Ruff is used as a linter. You can find the configuration in the pyproject.toml file.

ruff --help
Config
line-length = 100
extend-exclude = [
    "docs",
]
target-version = "py313"

[lint]
future-annotations = true
select = [
    "A",
    "B",
    "BLE",
    "C",
    "C4",
    "COM",
    "D",
    "E",
    "EM",
    "EXE",
    "F",
    "FA",
    "FLY",
    "G",
    "I",
    "ICN",
    "INP",
    "INT",
    "ISC",
    "N",
    "PERF",
    "PIE",
    "PLE",
    "PLC",
    "PLR",
    "PT",
    "PTH",
    "PYI",
    "Q",
    "RET",
    "RSE",
    "RUF",
    "SIM",
    "SLF",
    "SLOT",
    "T10",
    "TC",
    "TID",
    "TRY",
    "UP",
    "W",
    "YTT",
]
ignore = [
    "C408",
    "B905",
    "C901",
    "COM812",
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D106",
    "D107",
    "D203",
    "D204",
    "D213",
    "D215",
    "D400",
    "D401",
    "D404",
    "D406",
    "D407",
    "D408",
    "D409",
    "D413",
    "EM101",
    "EM102",
    "ISC001",
    "PLC0415",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "SLF001",
    "TRY003",
    "TC006",
]

[lint.flake8-quotes]
docstring-quotes = "double"

[lint.flake8-type-checking]
runtime-evaluated-base-classes = [
    "pydantic.BaseModel",
    "sqlalchemy.orm.DeclarativeBase",
    "schemez.Schema",
    "sqlmodel.SQLModel",
]
runtime-evaluated-decorators = [
    "pydantic.validate_call",
    "fastapi.FastAPI.get",
    "fastapi.FastAPI.post",
    "fastmcp.FastMCP.tool",
    "typer.Typer.command",
]

[lint.isort]
lines-after-imports = 2
force-sort-within-sections = true
combine-as-imports = true

[lint.mccabe]
max-complexity = 15

[lint.per-file-ignores]
"__init__.py" = [
    "E402",
    "I001",
]
"scripts/*" = [
    "INP001",
]
"*tests/*" = [
    "D100",
    "PLR2004",
]
"src/pyt3client/cli/app.py" = [
    "PLR0917",
]
"src/pyt3client/models/tools.py" = [
    "D",
    "E501",
    "N815",
    "RUF",
    "UP",
    "TC",
    "PIE790",
    "PYI051",
]

[format]
preview = true
Installing MkDocs

To install mkdocs:

pip install mkdocs
More information

Pre-Commit

This project uses pre-commit to ensure code quality. A .pre-commit-config.yaml configuration file tailored for this project is provided in the root folder.

# Setup pre-commit hooks for required formatting
pre-commit install
Config
default_language_version:
  python: python3.13
default_stages: [pre-commit]
repos:
  # Phase 1: Fast basic checks (fail early)
  - repo: https://github.com/pre-commit/pre-commit-hooks
    # https://pre-commit.com/hooks.html
    rev: v6.0.0
    hooks:
      - id: check-added-large-files
      - id: check-case-conflict
      - id: check-merge-conflict
      - id: check-toml
      - id: check-json
      - id: check-xml
      - id: check-yaml
        args: [--allow-multiple-documents, --unsafe]
      - id: detect-private-key
      - id: debug-statements

  # Phase 2: Code formatting (auto-fix, system commands)
  - repo: local
    hooks:
      - id: ruff-format
        name: ruff-format
        entry: uv run ruff format
        language: system
        types: [python]
        require_serial: true
      - id: ruff-fix
        name: ruff-fix
        entry: uv run ruff check --fix
        language: system
        types: [python]
        require_serial: true
      - id: tombi-format
        name: tombi-format
        entry: uv run tombi format pyproject.toml
        language: system
        files: ^pyproject\.toml$
        require_serial: true

  # Phase 3: Linting and type checking (system commands)
  - repo: local
    hooks:
      - id: ruff
        name: ruff
        entry: uv run ruff check
        language: system
        types: [python]
        require_serial: true
      - id: ty
        name: ty
        entry: uv run ty check
        language: system
        types: [python]
        pass_filenames: false
        require_serial: true

  # Phase 4: Tests (most expensive, system command)
  - repo: local
    hooks:
      - id: pytest-check
        name: pytest-check
        entry: uv run pytest
        language: system
        types: [python]
        pass_filenames: false
        always_run: true
        require_serial: true

  # Phase 5: Commit message validation (final)
  - repo: https://github.com/commitizen-tools/commitizen
    rev: v4.9.1
    hooks:
      - id: commitizen
        stages: [commit-msg]
        additional_dependencies: [typing-extensions]
Installing Pre-Commit

To install pre-commit:

pip install pre-commit
More information