Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Pyright is a static type checker for Python, designed to be fast and to work with large codebases. It helps developers catch type errors, enforce type consistency, and improve code quality.
Type Checking
Pyright can analyze Python files to check for type errors. This helps in identifying potential issues in the codebase early in the development process.
const pyright = require('pyright');
const result = pyright.analyze(['path/to/your/python/file.py']);
console.log(result);
Type Inference
Pyright can infer types in your Python code, even if you haven't explicitly annotated them. This feature helps in understanding the types being used throughout the codebase.
const pyright = require('pyright');
const result = pyright.analyze(['path/to/your/python/file.py']);
console.log(result.typeInference);
Configuration Options
Pyright allows for extensive configuration to tailor the type checking process to your project's needs. You can set the type checking mode, include or exclude specific files, and more.
const pyright = require('pyright');
const config = {
typeCheckingMode: 'strict',
include: ['src/**/*.py'],
exclude: ['tests/**/*.py']
};
const result = pyright.analyze(['path/to/your/python/file.py'], config);
console.log(result);
Mypy is another static type checker for Python. It is widely used and integrates well with existing Python codebases. Compared to Pyright, Mypy is more mature and has a larger user base, but Pyright is known for its speed and efficiency, especially with large codebases.
Pyright was created to address gaps in existing Python type checkers like mypy.
Pyright is typically 5x or more faster than mypy and other type checkers that are written in Python. It is meant for large Python source bases. It can run in a “watch” mode and performs fast incremental updates when files are modified.
Pyright is written in TypeScript and runs within node. It does not require a Python environment or imported third-party packages to be installed. This is especially useful when used with the VS Code editor, which uses node as its extension runtime.
Pyright supports flexible configuration that provides granular control over settings. Different “execution environments” can be specified for different subsets of a source base. Each environment can specify different PYTHONPATH settings, python language version, and platform target.
Pyright supports:
Pyright includes a recent copy of the stdlib type stubs from Typeshed. It can be configured to use another (perhaps more recent or modified) copy of the Typeshed type stubs. Of course, it also works with custom type stub files that are part of your project.
Pyright includes both a command-line tool and a Language Server Protocol plugin for VS Code.
Pyright offers the following language service features:
Pyright currently provides support for Python 3.0 and newer. There is currently no plan to support older versions.
Pyright is a work in progress. Type-checking capabilities are not fully implemented. For a list of incomplete functionality, refer to the TODO list below.
Q: What is the difference between pyright and the Microsoft Python VS Code plugin?
A: The Python VS Code plugin is the official Python support extension for VS Code. It is officially supported by a team of engineers at Microsoft. It supports a diverse array of features including debugging, linter plugins, type checking plugins, and much more. Pyright is focused entirely on type checking. It is a side project with no dedicated team.
Q: What is the difference between pyright and the Microsoft Python Language Server?
A: The Microsoft Python Language Server is a language server protocol (LSP) implementation that works with the Microsoft Python VS Code plugin, and it is officially supported by a team of Microsoft engineers. It also provides type checking capabilities. Pyright provides overlapping functionality but includes some unique features such as more configurabilty, command-line execution, and better performance.
You can install the latest-published version of the Pyright VS Code extension directly from VS Code. Simply open the extensions panel and search for pyright
.
The latest verison of the command-line tool can be installed with npm:
npm i pyright
To install it globally:
npm i -g pyright
To run the command-line tool:
npx pyright <options>
Pyright is a work in progress. The following functionality is not yet finished. If you would like to contribute to any of these areas, contact the maintainers of the repo.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
FAQs
Type checker for the Python language
The npm package pyright receives a total of 526,168 weekly downloads. As such, pyright popularity was classified as popular.
We found that pyright demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.