Pyright can not find root dir, single file mode

If I create an empty pyrightconfig.json file in the root directory of my project, everything work fine. But without this, it would not fallback to my current working directory. Here’s my Pyright config:

local util = require 'lspconfig/util'

require'lspconfig'.pyright.setup{
    on_attach = require'modules.lsp'.on_attach,
    cmd = { "pyright-langserver", "--stdio" },
    filetypes = { "python" },
    root_dir = function(fname)
        local root_files = {
            'pyproject.toml',
            'setup.py',
            'setup.cfg',
            'requirements.txt',
            'Pipfile',
            'pyrightconfig.json',
        }
        return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
    end,
    settings = {
        python = {
            analysis = {
                autoSearchPaths = true,
                diagnosticMode = "workspace",
                useLibraryCodeForTypes = false,
                typeCheckingMode = "off",
            },
        },
    },
}

Output of :LspInfo:

 Language client log: /Users/mater/.cache/nvim/lsp.log
 Detected filetype:   python
 
 2 client(s) attached to this buffer: 
 
 Client: efm (id: 1, pid: 90464, bufnr: [1])
 	filetypes:       lua, python, javascriptreact, javascript, sh, html, css, json, yaml
 	autostart:       true
 	root directory:  /Users/mater/Documents/projects/StyleGAN2
 	cmd:             efm-langserver
 
 Client: pyright (id: 2, pid: 90465, bufnr: [1])
 	filetypes:       python
 	autostart:       true
 	root directory:  Running in single file mode.
 	cmd:             pyright-langserver --stdio
 
 Configured servers list: pyright, efm, bashls

This is as designed, if it doesn’t find a root directory marker (like pyrightconfig.json, pyproject.toml, etc) it falls back to single file mode. I would suggest re-reading :help lspconfig