Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

add pyright to pre-commit hooks

Nick Sweetingfdba54fb34da
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 43a878378..44949625d 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -29,6 +29,7 @@ jobs:
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
+ - run: uv sync --dev --all-extras # install extras for examples to avoid pyright missing imports errors
- run: uv run pre-commit run --all-files --show-diff-on-failure
lint-typecheck:
@@ -39,5 +40,5 @@ jobs:
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- - run: uv sync --dev --all-extras # install extras for examples to avoid pyright missing imports errors
+ - run: uv sync --dev --all-extras # install extras for examples to avoid pyright missing imports errors-
- run: uv run pyright
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index dd9083eee..0daede158 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -29,6 +29,11 @@ repos:
- id: ruff-format
# see pyproject.toml for more details on ruff config
+ - repo: https://github.com/RobertCraigie/pyright-python
+ rev: v1.1.402
+ hooks:
+ - id: pyright
+
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
diff --git a/bin/lint.sh b/bin/lint.sh
index 0b2d1bacc..57099ebac 100755
--- a/bin/lint.sh
+++ b/bin/lint.sh
@@ -9,8 +9,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$SCRIPT_DIR/.." || exit 1
-echo "[*] Running ruff linter, formatter, and other pre-commit lint checks..."
-uv run pre-commit run --all-files
-
-echo "[*] Running pyright type checker..."
-exec uv run pyright
+echo "[*] Running ruff linter, formatter, pyright type checker, and other pre-commit checks..."
+exec uv run pre-commit run --all-files
diff --git a/pyproject.toml b/pyproject.toml
index 10b245460..487faa5ce 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -123,6 +123,8 @@ skip-magic-trailing-comma = false
[tool.pyright]
typeCheckingMode = "basic"
exclude = ["tests/old/", ".venv/", ".git/", "__pycache__/", "./test_*.py", "./debug_*.py", "private_example/"]
+venvPath = "."
+venv = ".venv"
[tool.hatch.build]