mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Update everything for main branch rename
This commit is contained in:
parent
7bb059ecba
commit
893d08be8c
2
.github/workflows/validation.yml
vendored
2
.github/workflows/validation.yml
vendored
@ -6,11 +6,9 @@ env:
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
jobs:
|
||||
|
@ -11,7 +11,7 @@ For absolute (non-relative) imports, Pyright employs the following resolution or
|
||||
|
||||
3. Try to resolve using **code within the workspace**.
|
||||
|
||||
* Try to resolve relative to the **root directory** of the execution environment. If no execution environments are specified in the config file, use the root of the workspace. For more information about execution environments, refer to the [configuration documentation](https://github.com/microsoft/pyright/blob/master/docs/configuration.md#execution-environment-options).
|
||||
* Try to resolve relative to the **root directory** of the execution environment. If no execution environments are specified in the config file, use the root of the workspace. For more information about execution environments, refer to the [configuration documentation](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#execution-environment-options).
|
||||
|
||||
* Try to resolve using any of the **extra paths** defined for the execution environment in the config file. If no execution environment applies, use the `python.analysis.extraPaths` setting. Extra paths are searched in the order in which they are provided in the config file or setting.
|
||||
|
||||
|
@ -14,26 +14,26 @@
|
||||
|
||||
## Core Concepts
|
||||
|
||||
Pyright implements a [service](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/service.ts), a persistent in-memory object that controls the order of analysis and provides an interface for the language server. For multi-root workspaces, each workspace gets its own service instance.
|
||||
Pyright implements a [service](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/service.ts), a persistent in-memory object that controls the order of analysis and provides an interface for the language server. For multi-root workspaces, each workspace gets its own service instance.
|
||||
|
||||
The service owns an instance of a [program](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/program.ts), which tracks the configuration file and all of the source files that make up the source base that is to be analyzed. A source file can be added to a program if it is a) referenced by the config file, b) currently open in the editor, or c) imported directly or indirectly by another source file. The program object is responsible for setting up file system watchers and updating the program as files are added, deleted, or edited. The program is also responsible for prioritizing all phases of analysis for all files, favoring files that are open in the editor (and their import dependencies).
|
||||
The service owns an instance of a [program](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/program.ts), which tracks the configuration file and all of the source files that make up the source base that is to be analyzed. A source file can be added to a program if it is a) referenced by the config file, b) currently open in the editor, or c) imported directly or indirectly by another source file. The program object is responsible for setting up file system watchers and updating the program as files are added, deleted, or edited. The program is also responsible for prioritizing all phases of analysis for all files, favoring files that are open in the editor (and their import dependencies).
|
||||
|
||||
The program tracks multiple [sourceFile](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/sourceFile.ts) objects. Each source file represents the contents of one Python source file on disk. It tracks the status of analysis for the file, including any intermediate or final results of the analysis and the diagnostics (errors and warnings) that result.
|
||||
The program tracks multiple [sourceFile](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/sourceFile.ts) objects. Each source file represents the contents of one Python source file on disk. It tracks the status of analysis for the file, including any intermediate or final results of the analysis and the diagnostics (errors and warnings) that result.
|
||||
|
||||
The program makes use of an [importResolver](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/importResolver.ts) to resolve the imported modules referenced within each source file.
|
||||
The program makes use of an [importResolver](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/importResolver.ts) to resolve the imported modules referenced within each source file.
|
||||
|
||||
|
||||
## Analysis Phases
|
||||
|
||||
Pyright performs the following analysis phases for each source file.
|
||||
|
||||
The [tokenizer](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/parser/tokenizer.ts) is responsible for converting the file’s string contents into a stream of tokens. White space, comments, and some end-of-line characters are ignored, as they are not needed by the parser.
|
||||
The [tokenizer](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/parser/tokenizer.ts) is responsible for converting the file’s string contents into a stream of tokens. White space, comments, and some end-of-line characters are ignored, as they are not needed by the parser.
|
||||
|
||||
The [parser](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/parser/parser.ts) is responsible for converting the token stream into a parse tree. A generalized [parseTreeWalker](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/parseTreeWalker.ts) provides a convenient way to traverse the parse tree. All subsequent analysis phases utilize the parseTreeWalker.
|
||||
The [parser](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/parser/parser.ts) is responsible for converting the token stream into a parse tree. A generalized [parseTreeWalker](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/parseTreeWalker.ts) provides a convenient way to traverse the parse tree. All subsequent analysis phases utilize the parseTreeWalker.
|
||||
|
||||
The [binder](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/binder.ts) is responsible for building scopes and populating the symbol table for each scope. It does not perform any type checking, but it detects and reports some semantic errors that will result in unintended runtime exceptions. It also detects and reports inconsistent name bindings (e.g. a variable that uses both a global and nonlocal binding in the same scope). The binder also builds a “reverse code flow graph” for each scope, allowing the type analyzer to determine a symbol’s type at any point in the code flow based on its antecedents.
|
||||
The [binder](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/binder.ts) is responsible for building scopes and populating the symbol table for each scope. It does not perform any type checking, but it detects and reports some semantic errors that will result in unintended runtime exceptions. It also detects and reports inconsistent name bindings (e.g. a variable that uses both a global and nonlocal binding in the same scope). The binder also builds a “reverse code flow graph” for each scope, allowing the type analyzer to determine a symbol’s type at any point in the code flow based on its antecedents.
|
||||
|
||||
The [checker](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/checker.ts) is responsible for checking all of the statements and expressions within a source file. It relies heavily on the [typeEvaluator](https://github.com/Microsoft/pyright/blob/master/packages/pyright-internal/src/analyzer/typeEvaluator.ts) module, which performs most of the heavy lifting. The checker doesn’t run on all files, only those that require full diagnostic output. For example, if a source file is not part of the program but is imported by the program, the checker doesn’t need to run on it.
|
||||
The [checker](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/checker.ts) is responsible for checking all of the statements and expressions within a source file. It relies heavily on the [typeEvaluator](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/typeEvaluator.ts) module, which performs most of the heavy lifting. The checker doesn’t run on all files, only those that require full diagnostic output. For example, if a source file is not part of the program but is imported by the program, the checker doesn’t need to run on it.
|
||||
|
||||
## Type Checking Concepts
|
||||
|
||||
|
@ -16,7 +16,7 @@ The Pyright VS Code extension honors the following settings.
|
||||
|
||||
**python.analysis.diagnosticMode** ["openFilesOnly", "workspace"]: Determines whether pyright analyzes (and reports errors for) all files in the workspace, as indicated by the config file. If this option is set to "openFilesOnly", pyright analyzes only open files.
|
||||
|
||||
**python.analysis.diagnosticSeverityOverrides** [map]: Allows a user to override the severity levels for individual diagnostic rules. "reportXXX" rules in the type check diagnostics settings in [configuration](https://github.com/microsoft/pyright/blob/master/docs/configuration.md#type-check-diagnostics-settings) are supported. Use the rule name as a key and one of "error," "warning," "information," "true," "false," or "none" as value.
|
||||
**python.analysis.diagnosticSeverityOverrides** [map]: Allows a user to override the severity levels for individual diagnostic rules. "reportXXX" rules in the type check diagnostics settings in [configuration](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#type-check-diagnostics-settings) are supported. Use the rule name as a key and one of "error," "warning," "information," "true," "false," or "none" as value.
|
||||
|
||||
**python.analysis.extraPaths** [array of paths]: Paths to add to the default execution environment extra paths if there are no execution environments defined in the config file.
|
||||
|
||||
|
@ -93,7 +93,7 @@ export function createFromRealFileSystem(
|
||||
// File watchers can give "changed" event even for a file open. but for those cases,
|
||||
// it will give relative path rather than absolute path. To get rid of such cases,
|
||||
// we will drop any event with relative paths. this trick is copied from VS Code
|
||||
// (https://github.com/microsoft/vscode/blob/master/src/vs/platform/files/node/watcher/unix/chokidarWatcherService.ts)
|
||||
// (https://github.com/microsoft/vscode/blob/main/src/vs/platform/files/node/watcher/unix/chokidarWatcherService.ts)
|
||||
export function ignoredWatchEventFunction(paths: string[]) {
|
||||
const normalizedPaths = paths.map((p) => p.toLowerCase());
|
||||
return (path: string): boolean => {
|
||||
|
@ -1299,7 +1299,7 @@ export abstract class LanguageServerBase implements LanguageServerInterface {
|
||||
protected getDocumentationUrlForDiagnosticRule(rule: string): string | undefined {
|
||||
// For now, return the same URL for all rules. We can separate these
|
||||
// in the future.
|
||||
return 'https://github.com/microsoft/pyright/blob/master/docs/configuration.md';
|
||||
return 'https://github.com/microsoft/pyright/blob/main/docs/configuration.md';
|
||||
}
|
||||
|
||||
protected abstract createProgressReporter(): ProgressReporter;
|
||||
|
@ -144,7 +144,7 @@ export class DocumentSymbolProvider {
|
||||
// Here are the rule of what symbols are indexed for a file.
|
||||
// 1. If it is a stub file, we index every public symbols defined by "https://www.python.org/dev/peps/pep-0484/#stub-files"
|
||||
// 2. If it is a py file and it is py.typed package, we index public symbols
|
||||
// defined by "https://github.com/microsoft/pyright/blob/master/docs/typed-libraries.md#library-interface"
|
||||
// defined by "https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface"
|
||||
// 3. If it is a py file and it is not py.typed package, we index only symbols that appear in
|
||||
// __all__ to make sure we don't include too many symbols in the index.
|
||||
|
||||
|
@ -52,4 +52,4 @@ The VS Code extension supports many time-saving language features including:
|
||||
|
||||
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.
|
||||
|
||||
For more details, refer to the [README](https://github.com/Microsoft/pyright/blob/master/README.md) on the Pyright GitHub site.
|
||||
For more details, refer to the [README](https://github.com/microsoft/pyright/blob/main/README.md) on the Pyright GitHub site.
|
||||
|
Loading…
Reference in New Issue
Block a user