Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/ci-integration.md
#	lerna.json
#	packages/pyright-internal/package-lock.json
#	packages/pyright-internal/package.json
#	packages/pyright-internal/src/analyzer/packageTypeVerifier.ts
#	packages/pyright-internal/src/common/configOptions.ts
#	packages/pyright-internal/src/tests/typeEvaluator4.test.ts
#	packages/pyright/package-lock.json
#	packages/pyright/package.json
#	packages/vscode-pyright/package-lock.json
#	packages/vscode-pyright/package.json
  • Loading branch information
DetachHead committed Mar 10, 2024
2 parents 58be00f + 1d658bb commit 31f4ffd
Show file tree
Hide file tree
Showing 184 changed files with 22,566 additions and 22,056 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
"program": "${workspaceFolder}/packages/pyright/index.js",
"args": ["${file}"]
},
{
"name": "Pyright CLI (pyright-internal)",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/packages/pyright-internal/debug.js",
"args": [
"--typeshedpath",
"${workspaceRoot}/packages/pyright-internal/typeshed-fallback",
"--version",
],
"internalConsoleOptions": "openOnSessionStart",
"outFiles": [
"${workspaceRoot}/packages/pyright-internal/out/**/*.js"
]
},
{
"name": "Pyright tests",
"type": "node",
Expand Down
2 changes: 1 addition & 1 deletion docs/build-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To install in VS Code, go to the extensions panel and choose “Install from VSI

## Debugging Pyright

To debug pyright, open the root source directory within VS Code. Open the debug sub-panel and choose “Pyright CLI” from the debug target menu. Click on the green “run” icon or press F5 to build and launch the command-line version in the VS Code debugger.
To debug pyright, open the root source directory within VS Code. Open the debug sub-panel and choose “Pyright CLI” from the debug target menu. Click on the green “run” icon or press F5 to build and launch the command-line version in the VS Code debugger. There's also a similar option that provides a slightly faster build/debug loop: make sure you've built the pyright-internal project e.g. with Terminal > Run Build Task > tsc: watch, then choose “Pyright CLI (pyright-internal)”.

To debug the VS Code extension, select “Pyright extension” from the debug target menu. Click on the green “run” icon or press F5 to build and launch a second copy of VS Code with the extension. Within the second VS Code instance, open a python source file so the pyright extension is loaded. Return to the first instance of VS Code and select “Pyright extension attach server” from the debug target menu and click the green “run” icon. This will attach the debugger to the process that hosts the type checker. You can now set breakpoints, etc.

Expand Down
2 changes: 1 addition & 1 deletion docs/ci-integration.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Integrating Pyright into Continuous Integration

see [the readme](../README.md#githubworkflowscheckyaml)
see [the readme](../README.md#githubworkflowscheckyaml)
4 changes: 2 additions & 2 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Pyright supports [configuration files](configuration.md) that provide granular c
* [PEP 681](https://www.python.org/dev/peps/pep-0681/) dataclass transform
* [PEP 692](https://www.python.org/dev/peps/pep-0692/) TypedDict for kwargs typing
* [PEP 695](https://www.python.org/dev/peps/pep-0695/) type parameter syntax
* [PEP 696](https://www.python.org/dev/peps/pep-0696/) (draft) type defaults for TypeVarLikes
* [PEP 696](https://www.python.org/dev/peps/pep-0696/) type defaults for TypeVarLikes
* [PEP 698](https://www.python.org/dev/peps/pep-0698/) override decorator for static typing
* [PEP 702](https://www.python.org/dev/peps/pep-0702/) marking deprecations
* [PEP 705](https://www.python.org/dev/peps/pep-0705/) (draft) TypedDict: read-only items
* [PEP 705](https://www.python.org/dev/peps/pep-0705/) TypedDict: read-only items
* [PEP 712](https://www.python.org/dev/peps/pep-0712/) (draft) converter parameter on dataclasses.field
* [PEP 728](https://www.python.org/dev/peps/pep-0728/) (draft) TypedDict with typed extra items
* [PEP 742](https://www.python.org/dev/peps/pep-0742/) (draft) narrowing types with TypeIs
Expand Down
2 changes: 1 addition & 1 deletion docs/type-concepts-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def func4(value: str | int) -> str:

If you later added another color to the `Color` enumeration above (e.g. `YELLOW = 4`), Pyright would detect that `func3` no longer exhausts all members of the enumeration and possibly returns `None`, which violates the declared return type. Likewise, if you modify the type of the `value` parameter in `func4` to expand the union, a similar error will be produced.

This “narrowing for implied else” technique works for all narrowing expressions listed above with the exception of simple falsey/truthy statements and type guards. It is also limited to simple names and doesn’t work with member access or index expressions. These are excluded because they are not generally used for exhaustive checks, and their inclusion would have a significant impact on analysis performance.
This “narrowing for implied else” technique works for all narrowing expressions listed above with the exception of simple falsey/truthy statements and type guards. It is also limited to simple names and doesn’t work with member access or index expressions, and it requires that the name has a declared type (an explicit type annotation). These limitations are imposed because this functionality would otherwise have significant impact on analysis performance.


### Narrowing Any
Expand Down
2 changes: 2 additions & 0 deletions packages/pyright-internal/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This is an entry-point for debugging the pyright CLI
require('./out/packages/pyright-internal/src/pyright').main();
Loading

0 comments on commit 31f4ffd

Please sign in to comment.