Skip to content

feat: typecheck python with pyrefly - #171

Open
iloveitaly wants to merge 1 commit into
masterfrom
cursor/pyrefly-275e
Open

iloveitaly wants to merge 1 commit into
masterfrom
cursor/pyrefly-275e

Conversation

@iloveitaly

Copy link
Copy Markdown
Owner

Motivation

Pyright was the Python type checker in lint, config, and the editor. Pyrefly is the replacement.

Description

  • Swap the pyright[nodejs] dev dependency for pyrefly 1.4.0.
  • Replace [tool.pyright] with [tool.pyrefly]. infer-with-first-use = false keeps empty containers as Any, matching pyright standard mode. Project excludes stay on local clones, generated migrations, playground, and tmp. Pyrefly already excludes node_modules, caches, and virtualenvs.
  • just py_lint runs pyrefly check. The default . passes no paths so project-excludes apply. CI uses --output-format=full-text-with-github and rewrites absolute paths to repo-relative annotation paths.
  • Editor: recommend meta.pyrefly, set python.languageServer to None, and disable Cursor's Pyright language services.
  • Drop PYRIGHT_PYTHON_PYLANCE_VERSION.
  • Fixes required for a clean check: production breakpoints use a no-op hook (None made breakpoint() raise TypeError), location fixtures are a TypedDict, and invalid quarters go through model_validate. posthog.default_client and TypeIDType.raw() keep a pyrefly ignore because the stubs do not describe the runtime types.

Screenshots / Test

  • just py_lint exits 0. Pyrefly reports 0 errors.
  • CI=1 just py_lint exits 0, including the GitHub annotation format.
  • just py_lint app/utils/address.py app/routes/utils/pydantic_lists.py exits 0 after the old pyright ignores were removed.
  • Invalid quarter numbers 0 and 5 still raise ValidationError.
  • pytest tests/unit/dates_test.py did not collect here: app startup could not resolve redis.workspace.orb.local.

Three warnings do not fail the command: deprecated client.charges, unreachable code after the early return in migrations/sanitize_production.py, and missing stubs for psutil.

Links

Open in Web Open in Cursor 

Replace the pyright dev dependency, project config, and lint recipe
with pyrefly, and point the editor at the Pyrefly language server.

Co-authored-by: Michael Bianco <mike@mikebian.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants