{"id":1946,"library":"basedpyright","title":"BasedPyright","description":"BasedPyright is a static type checker for Python, forked from Pyright. It aims to provide various type checking improvements, integrate Pylance features (previously exclusive to VS Code), and introduce new diagnostic rules. Unlike upstream Pyright, it is officially published on PyPI, removing the requirement for Node.js. It is actively maintained with frequent releases, currently at version 1.39.0.","status":"active","version":"1.39.0","language":"en","source_language":"en","source_url":"https://github.com/DetachHead/basedpyright","tags":["static analysis","type checking","linter","pyright","pylance"],"install":[{"cmd":"pip install basedpyright","lang":"bash","label":"Install with pip"},{"cmd":"uv add --dev basedpyright","lang":"bash","label":"Add to dev dependencies with uv"}],"dependencies":[{"reason":"Required to run the type checker.","package":"python","optional":false}],"imports":[],"quickstart":{"code":"mkdir my_project\ncd my_project\n\n# Create a Python file\necho 'def greet(name: str) -> str:\n    return \"Hello, \" + name\n\n# Intentional type error for demonstration\ndef add(a: int, b: str) -> int:\n    # Pyright will flag this: Expression of type \"str\" cannot be added to an expression of type \"int\"\n    return a + b' > main.py\n\n# Create a pyproject.toml for configuration\necho '[tool.basedpyright]\ninclude = [\"main.py\"]\nreportMissingTypeStubs = true\nreportPrivateUsage = true' > pyproject.toml\n\n# Run basedpyright\npip install basedpyright\nbasedpyright main.py","lang":"bash","description":"To get started, create a Python file and a `pyproject.toml` configuration. Then run `basedpyright` from your terminal. BasedPyright will analyze your code based on the rules specified in the configuration."},"warnings":[{"fix":"Consolidate your configuration into a single file, preferably `pyproject.toml` under the `[tool.basedpyright]` section, or ensure `pyrightconfig.json` is the sole source of truth.","message":"Configuration precedence: If both `pyrightconfig.json` and `pyproject.toml` are present in the project root, `pyrightconfig.json` will take precedence, and settings in `pyproject.toml` will be ignored.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add these settings to your `.vscode/settings.json`:\n```json\n{\n  \"python.analysis.typeCheckingMode\": \"off\",\n  \"basedpyright.disableLanguageServices\": true,\n  \"python.languageServer\": \"None\" \n}\n```","message":"VS Code / Pylance integration: When using BasedPyright with the Python extension (which includes Pylance) in VS Code, you must disable Pylance's type-checking (`\"python.analysis.typeCheckingMode\": \"off\"`) and BasedPyright's LSP features (`\"basedpyright.disableLanguageServices\": true`) in your `.vscode/settings.json` to prevent duplicated errors and conflicts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your configuration to use the `hint` category for these rules, e.g., `reportUnreachable = 'hint'`.","message":"Diagnostic categories for 'unreachable', 'unused', and 'deprecated' code were deprecated in favor of a more flexible 'hint' category in version 1.21.0. Configuration should now use 'hint' for these diagnostics.","severity":"deprecated","affected_versions":">=1.21.0"},{"fix":"Replace `type: ignore` with `pyright: ignore [ErrorCode]` where `[ErrorCode]` is the specific diagnostic rule you want to ignore.","message":"Unsafe `type: ignore` comments: `type: ignore` comments are considered unsafe and are disabled by default. BasedPyright recommends using `pyright: ignore` comments with specific error codes for better maintainability and safety.","severity":"gotcha","affected_versions":"All versions (disabled by default since early versions)"},{"fix":"Ensure your `pyproject.toml` or `pyrightconfig.json` adheres strictly to the documented schema. BasedPyright will report the specific configuration error.","message":"Invalid configuration files will cause `basedpyright` to exit with an error code (3). Unlike upstream Pyright, which might silently ignore invalid settings, BasedPyright is strict about configuration validity.","severity":"breaking","affected_versions":"All versions"},{"fix":"Enable and configure `reportUnreachable` in your `pyproject.toml` to catch these cases, or explicitly specify target `pythonVersion` and `pythonPlatform` in your config if the code is intended for specific environments.","message":"Unreachable code analysis: Pyright may not type-check code paths determined to be unreachable (e.g., in `if sys.version_info < (3, 10):` blocks if running on Python 3.10+), potentially leading to silent type errors. BasedPyright's `reportUnreachable` rule is designed to flag such unchecked code.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}