Skip to content

Make typechecking on by default for non-VSCode editors #1340

Open

Description

@ajc133

Describe the Bug

Hi, I'm trying to run pyrefly in neovim and not getting any type checking. Here are the error logs with timestamp and level removed). I've attached debug logs at the bottom as well

"rpc"	"pyrefly"	"stderr"	"starting generic LSP server\n"
"rpc"	"pyrefly"	"stderr"	"Reading messages\n"
"rpc"	"pyrefly"	"stderr"	"Request textDocument/semanticTokens/full (2) is canceled due to subsequent mutation\n"
"rpc"	"pyrefly"	"stderr"	"Could not decode `LspConfig` from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.\n"

Setting NVIM_APPNAME means my config comes from the below directory

# > echo $NVIM_APPNAME
nvim-pyrefly-reproducer
# > pwd
/home/ajc/.config/nvim-pyrefly-reproducer
# > ls
init.lua  test.py
# > cat init.lua 
vim.lsp.config['pyrefly'] ={
  cmd = { 'pyrefly', 'lsp' },
  filetypes = { 'python' },
  root_markers = {
    'pyrefly.toml',
    'pyproject.toml',
    'setup.py',
    'setup.cfg',
    'requirements.txt',
    'Pipfile',
    '.git',
  },
  on_exit = function(code, _, _)
    vim.notify('Closing Pyrefly LSP exited with code: ' .. code, vim.log.levels.INFO)
  end,
}
vim.lsp.set_log_level("debug")
vim.lsp.enable("pyrefly")

I open test.py, and there's no type checking for my obvious errors

def add(a: int, b: int) -> int:
    return a + b

add("a","b")

Running on linux. Pyrefly installed through uv tool install:

# > nvim --version
NVIM v0.11.4
Build type: RelWithDebInfo
LuaJIT 2.1.1753364724
Run "nvim -V1 -v" for more info
# > pyrefly --version
pyrefly 0.37.0

I've attached my full lsp.log from opening the file
lsp.log

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Activity

  1. Emilv2 commented on Oct 20, 2025

    @Emilv2

    You need a config for pyrefly in pyrefly.toml or pyproject.toml to enable type checking: https://github.com/facebook/pyrefly/releases/tag/0.32.0 (or set displayTypeErrors": "force-on" but I haven't figured out how do that in neovim). IMHO there should at least be a logging message reporting this, it took me also a while to figure out what was happening.

  2. ajc133 commented on Oct 21, 2025

    @ajc133
    Author

    Running pyrefly init did indeed solve my issue. Thank you. I only opened up this page and went straight to the neovim heading, in case that anecdata helps improve the docs . If I had read the beginning, I may have figured it out.

    Perhaps the neovim heading can suggest the user's run pyrefly init 🤷

    also yes, some command line flag to turn on type checking might be welcome for users that don't want to have a config anywhere

  3. added theissue type on Oct 21, 2025
  4. samwgoldman commented on Oct 21, 2025

    @samwgoldman
    Member

    Does the configuration suggested in this comment enable type errors without a config file? #1240 (comment)

    Please let me know if it works for you and I will update the docs to mention it.

  5. ajc133 commented on Oct 22, 2025

    @ajc133
    Author

    Yes, that works, thanks for the link! So with nvim-lspconfig installed, the minimal config block looks like this

    vim.lsp.config["pyrefly"] = {
      settings = {
        python = {
          pyrefly = {
            -- This mirrors VS Code's `"python.pyrefly.displayTypeErrors": "force-on"`
            displayTypeErrors = "force-on",
          },
        },
      },
    }
    vim.lsp.enable("pyrefly")
    
  6. ajc133 commented on Oct 22, 2025

    @ajc133
    Author

    At the risk of sounding obnoxious, it's too bad that type checking is disabled by default, especially since this is billed as a type checker and pyright-langserver does it by default.

    I'm sure there's there's been so much breath spent on this already though. Thanks again for the help!

  7. yangdanny97 commented on Oct 22, 2025

    @yangdanny97
    Collaborator

    Iirc the reason the default is set this way is because that's what Pylance does in VS Code. But I think what we do in VS Code doesn't necessarily have to be the same as what we do in other editors.

  8. changed the title [-]neovim 0.11.4 - 'Could not decode `LspConfig` from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.'[/-] [+]Make typechecking on by default for non-VSCode editors[/+] on Jan 15, 2026
  9. megapixel-code commented on Feb 9, 2026

    @megapixel-code

    I also do think the type checking should be on by default, I left my config without this setting thinking this was a problem with pyrefly because it was so new hoping to get an update with this fix.

    It's now fixed on my computer but maybe some less finicky users might just abandon this lsp for this reason.

  10. added this to the V1 Release milestone on Feb 10, 2026
  11. added
    needs-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.
    language-serverIssues specific to our IDE integration rather than type checking
    on Feb 10, 2026
  12. yangdanny97 commented on Feb 10, 2026

    @yangdanny97
    Collaborator

    Thanks for the input!

    We plan to gradually enable certain type errors by default over time, using a data-driven approach to decide what should be on-by-default, off-by-default, or strict-mode only.

    Recently, as of v0.52.0, we've taken a tiny step in that direction and enabled semantic syntax & parsing errors by default for all editors.

  13. removed this from the V1 Release milestone on Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    language-serverIssues specific to our IDE integration rather than type checkingneeds-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions