Static type checker for Python
Go to file
Rich Chiodo a5b352d929
Change all file paths to use a new URI class. (#6519)
* Preliminary idea

* First commit

* Refactor all uri based path functions to uriUtils

* Most of real code building

* More tests working

* More progress on the tests

* Rest of typecheck errors

* Move URIs even further to prevent accidental issues

* More tests

* Relative path fixes

* More test fixes and changes to 'startsWith'

* Uri tests all passing

* remove uri tests from path utils tests

* Fix relative paths for partial stub remapping

* Make isEmpty look empty and fix empty check for resolved paths

* Fix module name retrieval issue

* Use map instead of set for URI list

* Another path is empty fix.

* Fix importresolver finding source files for stubs

* Fixup actual defs to match expected format

* Relative path differences again

* Fix some comparisons

* More comparison fixes

* Config of ('.') was using current directory to find module names

* Shortcut empty URI for existence

* Add back ignoring case

* Fix regex matching

* All tests passing

* Fix build after merge

* Fix failing tests

* Fix rootDirectory and python path from interpreter

* Some perf improvements

* Don't bother reparsing in file system

* More tests and some logging output

* Extra data for analyzing slowness

* Fix build problems

* Refactor to not use vscode.URI except for initial parse

* Try without vscode uri validation

* Rework to new perf idea

* Split out class and interface

* All uri tests passing

* Fix other tests

* Cache results for faster perf

* Add memoization decorator

* combinePath remove one layer and make key gen faster

* Move caches local

* Generalize the memoization and optimize zero arg funcs

* Cache more stuff

* slight speedup for cache saving

* slight improvement by just returning the cached item

* Small optimization to skip loop if possible

* Further speedup for similar calls of combinePath

* Make it possible to switch between profiled and not

* Another small optimization

* Cache files in directory

* Small opt for isNativeModuleFileName

* Speed up getting pytyped info

* Fix command line parsing to expand ~
Slight perf improvement for exists cached by not splitting

* Split out instrumenting memoization

* Remove instrumented memoizationin

* Fix comment

* Fix build on ubuntu/mac

* Fix windows specific problems with tests
Fix auto import to work with windows file paths

* Fix command line output

* Try fixing CI path for failing test

* fix output paths in other spots

* More file output locations

* Output more data for failing test

* Put validation back and fix test

* Fix import cycles message to not show URI path

* Remove printing of config options

* More review feedback

* Missed a spot in the review feedback

* Fix build error

* Update packages/pyright-internal/src/analyzer/importResolver.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

* Update packages/pyright-internal/src/analyzer/analyzerFileInfo.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

* Update packages/pyright-internal/src/analyzer/backgroundAnalysisProgram.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

* Review feedback from Erik

* Revert changes to launch.json

* Fixup config options to use same roots as before

* Fix casing for cwd test on windows

* Fix spack differences

* Add back in the instrumentation until figure import resolve cache

* Fixup after merge

* Fix another equals comparison

* Merge error

* Fix after merge

* Fixup after merge

* Keep track of case sensitivity in the URIs

* Fix test failures on windows/mac

* Switch to the faster version

* Remove memoization

* Review feedback for some renames

* Review feedback

* Feedback from Erik, put back memoization for simple stuff

* fix prettier

* Fix typo and cache URI creations

* Add a comment

* Review feedback from Eric

* Fix crash in config options

* Missed a piece of feedback

---------

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
2023-12-07 09:15:39 -08:00
.github fix prettier 2023-11-17 11:17:37 -08:00
.vscode Change all file paths to use a new URI class. (#6519) 2023-12-07 09:15:39 -08:00
build pull-pylance-with-pyright-1.1.319 (#5584) 2023-07-26 09:30:40 -07:00
docs Added a new typeCheckingMode called "standard". It's a subset of "strict" but a superset of "basic". It is the new default mode, and it should cover all of the required checks for conformance with the Python typing standard. This addresses #66607. (#6627) 2023-12-01 23:44:12 -08:00
packages Change all file paths to use a new URI class. (#6519) 2023-12-07 09:15:39 -08:00
.eslintignore Mass reformat ts/js/md with ESLint quick fixes and prettier (#113) 2020-02-24 16:52:23 -08:00
.eslintrc.json Added new eslint rule to enforce that protected class variables and methods should never start with an underscore. We were somewhat inconsistent here. Fixed up the code to honor this rule. 2023-04-26 16:09:58 -07:00
.gitattributes Convert repo into a lerna monorepo, add a validation workflow (#978) 2020-08-28 19:46:48 -07:00
.gitignore Create test for virtual environment (#6007) 2023-09-25 10:21:21 -07:00
.prettierignore Convert repo into a lerna monorepo, add a validation workflow (#978) 2020-08-28 19:46:48 -07:00
.prettierrc Upgrade to Prettier 2.0, reformat (#610) 2020-04-07 17:18:22 -07:00
CONTRIBUTING.md Updated "contributing" text to recommend that an enhancement request be filed prior to submitting a PR. 2022-03-29 15:51:59 -06:00
lerna.json Published 1.1.339 2023-12-05 19:19:24 -08:00
LICENSE.txt Updated LICENSE and CONTRIBUTING files. 2019-03-17 22:05:33 -07:00
package-lock.json Upgraded to typescript 5.2. 2023-11-21 13:12:48 -08:00
package.json Change all file paths to use a new URI class. (#6519) 2023-12-07 09:15:39 -08:00
README.md Added link to pyright playground in main README. 2023-10-25 20:13:34 -07:00
SECURITY.md Microsoft mandatory file (#3477) 2022-05-18 15:28:38 -07:00
tsconfig.json Change all file paths to use a new URI class. (#6519) 2023-12-07 09:15:39 -08:00

Pyright

Static Type Checker for Python

Pyright is a full-featured, standards-based static type checker for Python. It is designed for high performance and can be used with large Python source bases.

Pyright includes both a command-line tool and an extension for Visual Studio Code.

Pyright Playground

Try Pyright in your browser using the Pyright Playground.

Documentation

Refer to the documentation for installation, configuration, and usage details.

Community

Do you have questions about Pyright or Python type annotations in general? Post your questions in the discussion section.

If you would like to report a bug or request an enhancement, file a new issue in either the pyright or pylance-release 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.

Contributing

This project welcomes contributions and suggestions. For feature and complex bug fix contributions, it is recommended that you first discuss the proposed change with Pyrights maintainers before submitting the pull request. 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.