From 8f722061b4dc40707e70ff76fd07b753f2d3bef2 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 29 Jun 2026 11:44:11 -0400 Subject: [PATCH] Add Enable Pyright Type Checking In Cursor as a Python TIL --- README.md | 3 ++- .../enable-pyright-type-checking-in-cursor.md | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 python/enable-pyright-type-checking-in-cursor.md diff --git a/README.md b/README.md index 96c8b36..560ba20 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1806 TILs and counting..._ +_1807 TILs and counting..._ See some of the other learning resources I work on: @@ -1072,6 +1072,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Define Typed Class Interface With Protocol](python/define-typed-class-interface-with-protocol.md) - [Dunder Methods](python/dunder-methods.md) - [Easy Key-Value Aggregates With defaultdict](python/easy-key-value-aggregates-with-defaultdict.md) +- [Enable Pyright Type Checking In Cursor](python/enable-pyright-type-checking-in-cursor.md) - [Get Absolute Seconds From `timedelta` Object](python/get-absolute-seconds-from-timedelta-object.md) - [Get Quotient And Remainder In One Operation](python/get-quotient-and-remainder-in-one-operation.md) - [Install With PIP For Specific Interpreter](python/install-with-pip-for-specific-interpreter.md) diff --git a/python/enable-pyright-type-checking-in-cursor.md b/python/enable-pyright-type-checking-in-cursor.md new file mode 100644 index 0000000..f8174db --- /dev/null +++ b/python/enable-pyright-type-checking-in-cursor.md @@ -0,0 +1,24 @@ +# Enable Pyright Type Checking In Cursor + +In most ways [Cursor](https://cursor.com/), a clone of VS Code, behaves like VS +Code and uses the same extensions as VS Code. It even offers to clone all your +existing extensions and setup from VS Code when you first install it. + +However, the Pyright type checking setup that I had in VS Code stopped working +when I opened up the same Python project in Cursor. It seems that to get Pyright +to reliably work with forks of VS Code, you need to use a compatible fork like +[Based Pyright](https://docs.basedpyright.com/latest/). + +Once I installed _Based Pyright_ from the extension marketplace, I was able to +enable it in `.vscode/settings.json`: + +```json +{ + ..., + "basedpyright.analysis.typeCheckingMode": "basic" +} +``` + +I may have needed to restart Cursor at this point, I cannot remember exactly. +However, once this setup was in place the helpful type checking errors started +appearing as red squiggles.