massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / README.md
1 ![Pyright](/docs/img/PyrightLarge.png)\r
2 \r
3 # Static type checker for Python\r
4 \r
5 ### Speed\r
6 Pyright is a fast type checker meant for large Python source bases. It can run in a “watch” mode and performs fast incremental updates when files are modified.\r
7 \r
8 ### Configurability\r
9 Pyright supports [configuration files](/docs/configuration.md) that provide granular control over settings. Different “execution environments” can be associated with subdirectories within a source base. Each environment can specify different module search paths, python language versions, and platform targets.\r
10 \r
11 ### Type Checking Features\r
12 * [PEP 484](https://www.python.org/dev/peps/pep-0484/) type hints including generics\r
13 * [PEP 487](https://www.python.org/dev/peps/pep-0487/) simpler customization of class creation\r
14 * [PEP 526](https://www.python.org/dev/peps/pep-0526/) syntax for variable annotations\r
15 * [PEP 544](https://www.python.org/dev/peps/pep-0544/) structural subtyping\r
16 * [PEP 561](https://www.python.org/dev/peps/pep-0561/) distributing and packaging type information\r
17 * [PEP 563](https://www.python.org/dev/peps/pep-0563/) postponed evaluation of annotations\r
18 * [PEP 570](https://www.python.org/dev/peps/pep-0570/) position-only parameters\r
19 * [PEP 585](https://www.python.org/dev/peps/pep-0585/) type hinting generics in standard collections\r
20 * [PEP 586](https://www.python.org/dev/peps/pep-0586/) literal types\r
21 * [PEP 589](https://www.python.org/dev/peps/pep-0589/) typed dictionaries\r
22 * [PEP 591](https://www.python.org/dev/peps/pep-0591/) final qualifier\r
23 * [PEP 593](https://www.python.org/dev/peps/pep-0593/) flexible variable annotations\r
24 * [PEP 604](https://www.python.org/dev/peps/pep-0604/) complementary syntax for unions\r
25 * [PEP 612](https://www.python.org/dev/peps/pep-0612/) parameter specification variables\r
26 * [PEP 613](https://www.python.org/dev/peps/pep-0613/) explicit type aliases\r
27 * [PEP 635](https://www.python.org/dev/peps/pep-0635/) structural pattern matching\r
28 * [PEP 646](https://www.python.org/dev/peps/pep-0646/) variadic generics\r
29 * [PEP 647](https://www.python.org/dev/peps/pep-0647/) user-defined type guards\r
30 * [PEP 655](https://www.python.org/dev/peps/pep-0655/) required typed dictionary items\r
31 * [PEP 673](https://www.python.org/dev/peps/pep-0673/) Self type\r
32 * Type inference for function return values, instance variables, class variables, and globals\r
33 * Type guards that understand conditional code flow constructs like if/else statements\r
34 \r
35 ### VS Code Integration\r
36 Pyright ships as both a command-line tool and a VS Code extension that provides many powerful features that help improve programming efficiency.\r
37 \r
38 ### VS Code Language Features\r
39 The VS Code extension supports many time-saving language features including:\r
40 \r
41 * Intelligent type completion of keywords, symbols, and import names appears when editing\r
42 * Import statements are automatically inserted when necessary for type completions\r
43 * Signature completion tips help when filling in arguments for a call\r
44 * Hover over symbols to provide type information and doc strings\r
45 * Find Definitions to quickly go to the location of a symbol’s definition\r
46 * Find References to find all references to a symbol within a code base\r
47 * Rename Symbol to rename all references to a symbol within a code base\r
48 * Find Symbols within the current document or within the entire workspace\r
49 * View call hierarchy information — calls made within a function and places where a function is called\r
50 * Organize Imports command for automatically ordering imports according to PEP8 rules\r
51 * Type stub generation for third-party libraries\r
52 \r
53 ### Built-in Type Stubs\r
54 Pyright includes a recent copy of the stdlib type stubs from [Typeshed](https://github.com/python/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.\r
55 \r
56 ### Command-line Tool or Visual Studio Code Extension\r
57 Pyright includes both a [command-line tool](/docs/command-line.md) and an [extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright) that implements the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/).\r
58 \r
59 For rich Python editing and debugging capabilities with Visual Studio Code, be sure to also install the official [Microsoft Python extension for Visual Studio Code](https://marketplace.visualstudio.com/itemdetails?itemName=ms-python.python) as Pyright only provides syntax and type checking.\r
60 \r
61 \r
62 ## Installation\r
63 ### VS Code Extension\r
64 For most VS Code users, we recommend using the Pylance extension rather than Pyright. Pylance incorporates the pyright type checker but features additional capabilities such as IntelliCode and semantic token highlighting. You can install the latest-published version of the Pylance VS Code extension directly from VS Code. Simply open the extensions panel and search for `pylance`.\r
65 \r
66 ### Vim\r
67 For vim/neovim users, you can install [coc-pyright](https://github.com/fannheyward/coc-pyright), the Pyright extension for coc.nvim.\r
68 \r
69 Alternatively, [ALE](https://github.com/dense-analysis/ale) will automatically check your code with Pyright, without requiring any additional configuration.\r
70 \r
71 ### Sublime Text\r
72 For sublime text users, you can install the [LSP-pyright](https://github.com/sublimelsp/LSP-pyright) plugin from [package control](https://packagecontrol.io/packages/LSP-pyright).\r
73 \r
74 ### Emacs\r
75 For emacs users, you can install [lsp-mode](https://github.com/emacs-lsp/lsp-mode) that includes [lsp-pyright](https://github.com/emacs-lsp/lsp-pyright).\r
76 To activate the pyright extension follow the instructions in the [docs](https://emacs-lsp.github.io/lsp-pyright/).\r
77 \r
78 ### Command-line\r
79 The latest version of the command-line tool can be installed with npm, which is part of node. If you don't have a recent version of node on your system, install that first from [nodejs.org](https://nodejs.org). \r
80 \r
81 To install pyright globally:\r
82 `npm install -g pyright`\r
83 \r
84 On MacOS or Linux, sudo is required to install globally:\r
85 `sudo npm install -g pyright`\r
86 \r
87 Once installed, you can run the tool from the command line as follows:\r
88 `pyright <options>`\r
89 \r
90 To update to the latest version:\r
91 `sudo npm update -g pyright`\r
92 \r
93 \r
94 ## Using Pyright with VS Code Python Extension\r
95 Pyright’s type-checking functionality and language features are now incorporated into a VS Code extension called [Pylance](https://github.com/microsoft/pylance-release), the officially supported Python Language Server from Microsoft. Pylance is designed to work with the Python extension for VS Code. In addition to Pyright’s functionality, Pylance adds compatibility with several advanced features including IntelliCode for AI-assisted completions. If you are a VS Code user, we recommend that you uninstall Pyright and instead install Pylance. You will get all the benefits of Pyright and more! \r
96 \r
97 \r
98 ## Documentation\r
99 * [Getting Started with Type Checking](/docs/getting-started.md)\r
100 * [Type Concepts](/docs/type-concepts.md)\r
101 * [Continuous Integration (CI)](/docs/ci-integration.md)\r
102 * [Command-line Options](/docs/command-line.md)\r
103 * [Configuration](/docs/configuration.md)\r
104 * [Settings](/docs/settings.md)\r
105 * [Comments](/docs/comments.md)\r
106 * [Type Inference](/docs/type-inference.md)\r
107 * [Import Resolution](/docs/import-resolution.md)\r
108 * [Type Stubs](/docs/type-stubs.md)\r
109 * [Types in Libraries](/docs/typed-libraries.md)\r
110 * [Commands](/docs/commands.md)\r
111 * [Building & Debugging](/docs/build-debug.md)\r
112 * [Pyright Internals](/docs/internals.md)\r
113 \r
114 For additional information about Python static typing, refer to this community-maintained [Python Type School](https://github.com/python/typing/discussions).\r
115 \r
116 ## Limitations\r
117 Pyright provides support for Python 3.0 and newer. There is currently no plan to support older versions.\r
118 \r
119 \r
120 ## Community\r
121 Do you have questions about Pyright or Python type annotations in general? Post your questions in [the discussion section](https://github.com/microsoft/pyright/discussions).\r
122 \r
123 If you would like to report a bug or request an enhancement, file a new issue in either the [pyright](https://github.com/microsoft/pyright/issues) or [pylance-release](https://github.com/microsoft/pylance-release/issues) issue tracker. In general, core type checking functionality is associated with pyright while language service functionality is associated with pylance, but the same contributors monitor both repos. For best results, provide the information requested in the issue template.\r
124 \r
125 \r
126 ## FAQ\r
127 **Q:** What is the difference between Pyright and [Pylance](https://github.com/microsoft/pylance-release)? \r
128 \r
129 **A:** Pyright is an open-source Python type checker and language server. Pylance leverages Pyright’s functionality with additional features, some of which are not open-sourced. \r
130 \r
131 **Q:** What is the long-term plan for Pyright?\r
132 \r
133 **A:** Pyright is now an officially-supported Microsoft type checker for Python. It will continue to be developed and maintained as an open-source project under its original MIT license terms. The Pyright extension for VSCode is a reference implementation and is not guaranteed to be fully functional or maintained long-term.\r
134 \r
135 \r
136 ## Contributing\r
137 \r
138 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.\r
139 \r
140 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.\r
141 \r
142 This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\r