├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── 3_feature_request.md │ └── config.yml ├── actions │ ├── build-vsix │ │ └── action.yml │ ├── lint │ │ └── action.yml │ └── smoke-tests │ │ └── action.yml ├── dependabot.yml ├── release.yml ├── release_plan.md └── workflows │ ├── build.yml │ ├── codeql-analysis.yml │ ├── community-feedback-auto-comment.yml │ ├── getLabels.js │ ├── info-needed-closer.yml │ ├── issue-labels.yml │ ├── lock-issues.yml │ ├── pr-check.yml │ ├── pr-file-check.yml │ ├── pr-labels.yml │ ├── python27-issue-response.yml │ ├── remove-needs-labels.yml │ ├── test-plan-item-validator.yml │ └── triage-info-needed.yml ├── .gitignore ├── .npmrc ├── .nvmrc ├── .prettierrc.js ├── .sonarcloud.properties ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ThirdPartyNotices-Repository.txt ├── build ├── .mocha-multi-reporters.config ├── .mocha.functional.json ├── .mocha.functional.perf.json ├── .mocha.perf.config ├── .mocha.performance.json ├── .mocha.unittests.js.json ├── .mocha.unittests.json ├── .mocha.unittests.ts.json ├── .nycrc ├── azure-pipeline.pre-release.yml ├── azure-pipeline.stable.yml ├── azure-pipelines │ ├── pipeline.yml │ └── templates │ │ ├── pack-steps.yml │ │ └── test-steps.yml ├── build-install-requirements.txt ├── ci │ ├── addEnvPath.py │ ├── conda_base.yml │ ├── conda_env_1.yml │ ├── conda_env_2.yml │ ├── pyproject.toml │ ├── scripts │ │ └── spec_with_pid.js │ └── static_analysis │ │ └── policheck │ │ └── exceptions.mdb ├── constants.js ├── contributedFiles.json ├── existingFiles.json ├── fail.js ├── functional-test-requirements.txt ├── license-header.txt ├── test-requirements.txt ├── test_update_ext_version.py ├── unlocalizedFiles.json ├── update_ext_version.py ├── update_package_file.py ├── util.js └── webpack │ ├── common.js │ ├── loaders │ ├── externalizeDependencies.js │ ├── jsonloader.js │ └── remarkLoader.js │ ├── nativeOrInteractivePicker.html │ ├── webpack.extension.browser.config.js │ ├── webpack.extension.config.js │ └── webpack.extension.dependencies.config.js ├── cgmanifest.json ├── data ├── .vscode │ └── settings.json └── test.py ├── gulpfile.js ├── images ├── activeWorkspaceEnv.mp4 ├── createEnvs.mp4 ├── createVenv.mp4 ├── managePackages.mp4 ├── workspaceEnvs.mp4 └── workspaceEnvs.png ├── package-lock.json ├── package.json ├── package.nls.json ├── pythonFiles ├── .env ├── .vscode │ └── settings.json ├── Notebooks intro.ipynb ├── create_conda.py ├── create_microvenv.py ├── create_venv.py ├── download_get_pip.py ├── get_output_via_markers.py ├── install_debugpy.py ├── installed_check.py ├── interpreterInfo.py ├── jedilsp_requirements │ ├── requirements.in │ └── requirements.txt ├── linter.py ├── normalizeSelection.py ├── printEnvVariables.py ├── printEnvVariablesToFile.py ├── pyproject.toml ├── run-jedi-language-server.py ├── shell_exec.py ├── tensorboard_launcher.py ├── testing_tools │ ├── __init__.py │ ├── adapter │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── discovery.py │ │ ├── errors.py │ │ ├── info.py │ │ ├── pytest │ │ │ ├── __init__.py │ │ │ ├── _cli.py │ │ │ ├── _discovery.py │ │ │ └── _pytest_item.py │ │ ├── report.py │ │ └── util.py │ ├── process_json_util.py │ ├── run_adapter.py │ ├── socket_manager.py │ └── unittest_discovery.py ├── testlauncher.py ├── tests │ ├── __init__.py │ ├── __main__.py │ ├── debug_adapter │ │ ├── __init__.py │ │ └── test_install_debugpy.py │ ├── pytestadapter │ │ ├── .data │ │ │ ├── dual_level_nested_folder │ │ │ │ ├── nested_folder_one │ │ │ │ │ └── test_bottom_folder.py │ │ │ │ └── test_top_folder.py │ │ │ ├── empty_discovery.py │ │ │ ├── error_parametrize_discovery.py │ │ │ ├── error_pytest_import.txt │ │ │ ├── error_raise_exception.py │ │ │ ├── error_syntax_discovery.txt │ │ │ ├── folder_a │ │ │ │ └── folder_b │ │ │ │ │ └── folder_a │ │ │ │ │ └── test_nest.py │ │ │ ├── param_same_name │ │ │ │ ├── test_param1.py │ │ │ │ └── test_param2.py │ │ │ ├── parametrize_tests.py │ │ │ ├── root │ │ │ │ └── tests │ │ │ │ │ ├── pytest.ini │ │ │ │ │ ├── test_a.py │ │ │ │ │ └── test_b.py │ │ │ ├── simple_pytest.py │ │ │ ├── skip_tests.py │ │ │ ├── text_docstring.txt │ │ │ ├── unittest_folder │ │ │ │ ├── test_add.py │ │ │ │ └── test_subtract.py │ │ │ ├── unittest_pytest_same_file.py │ │ │ └── unittest_skiptest_file_level.py │ │ ├── __init__.py │ │ ├── expected_discovery_test_output.py │ │ ├── expected_execution_test_output.py │ │ ├── helpers.py │ │ ├── test_discovery.py │ │ └── test_execution.py │ ├── run_all.py │ ├── test_create_conda.py │ ├── test_create_microvenv.py │ ├── test_create_venv.py │ ├── test_data │ │ ├── missing-deps.data │ │ ├── no-missing-deps.data │ │ ├── pyproject-missing-deps.data │ │ └── pyproject-no-missing-deps.data │ ├── test_installed_check.py │ ├── test_normalize_selection.py │ ├── testing_tools │ │ ├── __init__.py │ │ └── adapter │ │ │ ├── .data │ │ │ ├── NormCase │ │ │ │ └── tests │ │ │ │ │ ├── A │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── b │ │ │ │ │ │ ├── C │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ └── test_Spam.py │ │ │ │ │ │ └── __init__.py │ │ │ │ │ └── __init__.py │ │ │ ├── complex │ │ │ │ ├── README.md │ │ │ │ ├── mod.py │ │ │ │ └── tests │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── spam.py │ │ │ │ │ ├── test_42-43.py │ │ │ │ │ ├── test_42.py │ │ │ │ │ ├── test_doctest.py │ │ │ │ │ ├── test_doctest.txt │ │ │ │ │ ├── test_foo.py │ │ │ │ │ ├── test_mixed.py │ │ │ │ │ ├── test_pytest.py │ │ │ │ │ ├── test_pytest_param.py │ │ │ │ │ ├── test_unittest.py │ │ │ │ │ ├── testspam.py │ │ │ │ │ ├── v │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── spam.py │ │ │ │ │ ├── test_eggs.py │ │ │ │ │ ├── test_ham.py │ │ │ │ │ └── test_spam.py │ │ │ │ │ ├── w │ │ │ │ │ ├── test_spam.py │ │ │ │ │ └── test_spam_ex.py │ │ │ │ │ └── x │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── y │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── z │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── a │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── test_spam.py │ │ │ │ │ ├── b │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── test_spam.py │ │ │ │ │ └── test_ham.py │ │ │ ├── notests │ │ │ │ └── tests │ │ │ │ │ └── __init__.py │ │ │ ├── simple │ │ │ │ └── tests │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── test_spam.py │ │ │ └── syntax-error │ │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_spam.py │ │ │ ├── __init__.py │ │ │ ├── pytest │ │ │ ├── __init__.py │ │ │ ├── test_cli.py │ │ │ └── test_discovery.py │ │ │ ├── test___main__.py │ │ │ ├── test_discovery.py │ │ │ ├── test_functional.py │ │ │ ├── test_report.py │ │ │ └── test_util.py │ ├── unittestadapter │ │ ├── .data │ │ │ ├── discovery_empty.py │ │ │ ├── discovery_error │ │ │ │ ├── file_one.py │ │ │ │ └── file_two.py │ │ │ ├── discovery_simple.py │ │ │ ├── test_fail_simple.py │ │ │ ├── test_subtest.py │ │ │ ├── test_two_classes.py │ │ │ ├── two_patterns │ │ │ │ ├── pattern_a_test.py │ │ │ │ └── test_pattern_b.py │ │ │ ├── unittest_folder │ │ │ │ ├── test_add.py │ │ │ │ └── test_subtract.py │ │ │ ├── unittest_skip │ │ │ │ ├── unittest_skip_file.py │ │ │ │ └── unittest_skip_function.py │ │ │ ├── utils_decorated_tree.py │ │ │ ├── utils_nested_cases │ │ │ │ ├── file_one.py │ │ │ │ └── folder │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── file_two.py │ │ │ ├── utils_simple_cases.py │ │ │ └── utils_simple_tree.py │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── expected_discovery_test_output.py │ │ ├── helpers.py │ │ ├── test_discovery.py │ │ ├── test_execution.py │ │ └── test_utils.py │ └── util.py ├── unittestadapter │ ├── __init__.py │ ├── discovery.py │ ├── execution.py │ └── utils.py ├── visualstudio_py_testlauncher.py ├── vscode_datascience_helpers │ └── tests │ │ └── logParser.py └── vscode_pytest │ ├── __init__.py │ └── run_pytest_script.py ├── requirements.in ├── requirements.txt ├── resources ├── dark │ ├── debug.svg │ ├── discovering-tests.svg │ ├── export_to_python.svg │ ├── open-file.svg │ ├── play.svg │ ├── refresh.svg │ ├── repl.svg │ ├── restart-kernel.svg │ ├── run-failed-tests.svg │ ├── run-file.svg │ ├── run-tests.svg │ ├── start.svg │ ├── status-error.svg │ ├── status-ok.svg │ ├── status-unknown.svg │ ├── stop.svg │ ├── trusted.svg │ └── un-trusted.svg ├── demo.gif ├── light │ ├── debug.svg │ ├── discovering-tests.svg │ ├── export_to_python.svg │ ├── open-file.svg │ ├── play.svg │ ├── refresh.svg │ ├── repl.svg │ ├── restart-kernel.svg │ ├── run-failed-tests.svg │ ├── run-file.svg │ ├── run-tests.svg │ ├── start.svg │ ├── status-error.svg │ ├── status-ok.svg │ ├── status-unknown.svg │ ├── stop.svg │ ├── trusted.svg │ └── un-trusted.svg ├── logo.svg ├── report_issue_template.md ├── report_issue_user_settings.json └── walkthrough │ ├── create-environment.svg │ ├── create-notebook.svg │ ├── data-science.svg │ ├── environments-info.md │ ├── install-python-linux.md │ ├── install-python-macos.md │ ├── install-python-windows-8.md │ ├── interactive-window.svg │ ├── learnmore.svg │ ├── open-folder.svg │ ├── play-button-dark.png │ ├── python-interpreter.svg │ └── rundebug2.svg ├── scripts └── onCreateCommand.sh ├── src ├── client │ ├── .gitignore │ ├── .vscodeignore │ ├── activation │ │ ├── activationManager.ts │ │ ├── serviceRegistry.ts │ │ └── types.ts │ ├── common │ │ ├── application │ │ │ ├── activeResource.ts │ │ │ ├── applicationEnvironment.ts │ │ │ ├── applicationShell.ts │ │ │ ├── commandManager.ts │ │ │ ├── commands.ts │ │ │ ├── documentManager.ts │ │ │ ├── terminalManager.ts │ │ │ ├── types.ts │ │ │ └── workspace.ts │ │ ├── cancellation.ts │ │ ├── configSettings.ts │ │ ├── configuration │ │ │ ├── executionSettings │ │ │ │ └── pipEnvExecution.ts │ │ │ └── service.ts │ │ ├── constants.ts │ │ ├── contextKey.ts │ │ ├── editor.ts │ │ ├── errors │ │ │ ├── errorUtils.ts │ │ │ └── moduleNotInstalledError.ts │ │ ├── extensions.ts │ │ ├── helpers.ts │ │ ├── persistentState.ts │ │ ├── platform │ │ │ ├── errors.ts │ │ │ ├── fileSystem.ts │ │ │ ├── fileSystemWatcher.ts │ │ │ ├── fs-paths.ts │ │ │ ├── fs-temp.ts │ │ │ ├── pathUtils.ts │ │ │ ├── platformService.ts │ │ │ ├── registry.ts │ │ │ ├── serviceRegistry.ts │ │ │ └── types.ts │ │ ├── process │ │ │ ├── constants.ts │ │ │ ├── currentProcess.ts │ │ │ ├── decoder.ts │ │ │ ├── internal │ │ │ │ ├── python.ts │ │ │ │ └── scripts │ │ │ │ │ ├── constants.ts │ │ │ │ │ └── index.ts │ │ │ ├── logger.ts │ │ │ ├── proc.ts │ │ │ ├── processFactory.ts │ │ │ ├── pythonEnvironment.ts │ │ │ ├── pythonExecutionFactory.ts │ │ │ ├── pythonProcess.ts │ │ │ ├── pythonToolService.ts │ │ │ ├── rawProcessApis.ts │ │ │ ├── serviceRegistry.ts │ │ │ └── types.ts │ │ ├── serviceRegistry.ts │ │ ├── stringUtils.ts │ │ ├── terminal │ │ │ ├── activator │ │ │ │ ├── base.ts │ │ │ │ └── index.ts │ │ │ ├── environmentActivationProviders │ │ │ │ ├── baseActivationProvider.ts │ │ │ │ ├── bash.ts │ │ │ │ ├── commandPrompt.ts │ │ │ │ ├── condaActivationProvider.ts │ │ │ │ ├── nushell.ts │ │ │ │ ├── pipEnvActivationProvider.ts │ │ │ │ └── pyenvActivationProvider.ts │ │ │ ├── factory.ts │ │ │ ├── helper.ts │ │ │ ├── service.ts │ │ │ ├── shellDetector.ts │ │ │ ├── shellDetectors │ │ │ │ ├── baseShellDetector.ts │ │ │ │ ├── settingsShellDetector.ts │ │ │ │ ├── terminalNameShellDetector.ts │ │ │ │ ├── userEnvironmentShellDetector.ts │ │ │ │ └── vscEnvironmentShellDetector.ts │ │ │ ├── syncTerminalService.ts │ │ │ └── types.ts │ │ ├── types.ts │ │ ├── utils │ │ │ ├── arrayUtils.ts │ │ │ ├── async.ts │ │ │ ├── cacheUtils.ts │ │ │ ├── decorators.ts │ │ │ ├── delayTrigger.ts │ │ │ ├── enum.ts │ │ │ ├── exec.ts │ │ │ ├── filesystem.ts │ │ │ ├── icons.ts │ │ │ ├── localize.ts │ │ │ ├── misc.ts │ │ │ ├── multiStepInput.ts │ │ │ ├── platform.ts │ │ │ ├── random.ts │ │ │ ├── regexp.ts │ │ │ ├── resourceLifecycle.ts │ │ │ ├── stopWatch.ts │ │ │ ├── sysTypes.ts │ │ │ ├── version.ts │ │ │ └── workerPool.ts │ │ ├── variables │ │ │ ├── environment.ts │ │ │ ├── environmentVariablesProvider.ts │ │ │ ├── serviceRegistry.ts │ │ │ ├── systemVariables.ts │ │ │ └── types.ts │ │ └── vscodeApis │ │ │ ├── commandApis.ts │ │ │ ├── windowApis.ts │ │ │ └── workspaceApis.ts │ ├── components.ts │ ├── constants.ts │ ├── extension.ts │ ├── extensionActivation.ts │ ├── extensionInit.ts │ ├── interpreter │ │ ├── activation │ │ │ ├── service.ts │ │ │ ├── terminalEnvVarCollectionService.ts │ │ │ └── types.ts │ │ ├── configuration │ │ │ ├── environmentTypeComparer.ts │ │ │ ├── interpreterSelector │ │ │ │ ├── commands │ │ │ │ │ ├── base.ts │ │ │ │ │ └── setInterpreter.ts │ │ │ │ └── interpreterSelector.ts │ │ │ └── types.ts │ │ ├── contracts.ts │ │ ├── helpers.ts │ │ ├── interpreterService.ts │ │ ├── locators │ │ │ └── types.ts │ │ └── serviceRegistry.ts │ ├── ioc │ │ ├── container.ts │ │ ├── serviceManager.ts │ │ └── types.ts │ ├── logging │ │ ├── index.ts │ │ ├── outputChannelLogger.ts │ │ ├── types.ts │ │ └── util.ts │ ├── pythonEnvironments │ │ ├── api.ts │ │ ├── base │ │ │ ├── info │ │ │ │ ├── env.ts │ │ │ │ ├── envKind.ts │ │ │ │ ├── environmentInfoService.ts │ │ │ │ ├── executable.ts │ │ │ │ ├── index.ts │ │ │ │ ├── interpreter.ts │ │ │ │ └── pythonVersion.ts │ │ │ ├── locator.ts │ │ │ ├── locatorUtils.ts │ │ │ ├── locators.ts │ │ │ ├── locators │ │ │ │ ├── common │ │ │ │ │ └── resourceBasedLocator.ts │ │ │ │ ├── composite │ │ │ │ │ ├── envsCollectionCache.ts │ │ │ │ │ ├── envsCollectionService.ts │ │ │ │ │ ├── envsReducer.ts │ │ │ │ │ ├── envsResolver.ts │ │ │ │ │ └── resolverUtils.ts │ │ │ │ ├── lowLevel │ │ │ │ │ ├── activeStateLocator.ts │ │ │ │ │ ├── condaLocator.ts │ │ │ │ │ ├── customVirtualEnvLocator.ts │ │ │ │ │ ├── filesLocator.ts │ │ │ │ │ ├── fsWatchingLocator.ts │ │ │ │ │ ├── globalVirtualEnvronmentLocator.ts │ │ │ │ │ ├── microsoftStoreLocator.ts │ │ │ │ │ ├── poetryLocator.ts │ │ │ │ │ ├── posixKnownPathsLocator.ts │ │ │ │ │ ├── pyenvLocator.ts │ │ │ │ │ ├── windowsKnownPathsLocator.ts │ │ │ │ │ ├── windowsRegistryLocator.ts │ │ │ │ │ └── workspaceVirtualEnvLocator.ts │ │ │ │ └── wrappers.ts │ │ │ ├── watcher.ts │ │ │ └── watchers.ts │ │ ├── common │ │ │ ├── commonUtils.ts │ │ │ ├── environmentIdentifier.ts │ │ │ ├── environmentManagers │ │ │ │ ├── activestate.ts │ │ │ │ ├── conda.ts │ │ │ │ ├── condaService.ts │ │ │ │ ├── globalInstalledEnvs.ts │ │ │ │ ├── macDefault.ts │ │ │ │ ├── microsoftStoreEnv.ts │ │ │ │ ├── pipenv.ts │ │ │ │ ├── poetry.ts │ │ │ │ ├── pyenv.ts │ │ │ │ └── simplevirtualenvs.ts │ │ │ ├── externalDependencies.ts │ │ │ ├── posixUtils.ts │ │ │ ├── pythonBinariesWatcher.ts │ │ │ ├── windowsRegistry.ts │ │ │ └── windowsUtils.ts │ │ ├── creation │ │ │ ├── common │ │ │ │ ├── commonUtils.ts │ │ │ │ └── workspaceSelection.ts │ │ │ ├── createEnvApi.ts │ │ │ ├── createEnvButtonContext.ts │ │ │ ├── createEnvironment.ts │ │ │ ├── proposed.createEnvApis.ts │ │ │ ├── provider │ │ │ │ ├── condaCreationProvider.ts │ │ │ │ ├── condaProgressAndTelemetry.ts │ │ │ │ ├── condaUtils.ts │ │ │ │ ├── venvCreationProvider.ts │ │ │ │ ├── venvDeleteUtils.ts │ │ │ │ ├── venvProgressAndTelemetry.ts │ │ │ │ ├── venvSwitchPython.ts │ │ │ │ └── venvUtils.ts │ │ │ ├── registrations.ts │ │ │ └── types.ts │ │ ├── exec.ts │ │ ├── index.ts │ │ ├── info │ │ │ ├── executable.ts │ │ │ ├── index.ts │ │ │ ├── interpreter.ts │ │ │ └── pythonVersion.ts │ │ └── legacyIOC.ts │ ├── telemetry │ │ ├── constants.ts │ │ ├── index.ts │ │ └── types.ts │ ├── testing │ │ └── common │ │ │ └── helpers.ts │ └── types.ts └── environments │ ├── activeInterpreter.ts │ ├── cache.ts │ ├── constants.ts │ ├── envCreation.ts │ ├── envDeletion.ts │ ├── environments.ts │ ├── helpers.ts │ ├── installPython.ts │ ├── micromamba │ ├── base.ts │ ├── constants.ts │ ├── downloader.ts │ ├── install.ts │ └── shells.ts │ ├── packageSearch.ts │ ├── packages.ts │ ├── serviceRegistry.ts │ ├── sillyDI.ts │ ├── terminal.ts │ ├── tools │ ├── conda.ts │ ├── pip.ts │ ├── poetry.ts │ ├── pyenv.ts │ └── venv.ts │ ├── utils.ts │ └── view │ ├── commands.ts │ ├── envTreeDataProvider.ts │ ├── environmentsTreeDataProvider.ts │ ├── foldersTreeDataProvider.ts │ └── types.ts ├── tsconfig.extension.json ├── tsconfig.json ├── tsfmt.json ├── types ├── src │ └── vscode-dts │ │ └── vscode.proposed.envCollectionOptions.d.ts └── vscode.proposed.envShellEvent.d.ts ├── typings ├── dom.fix.rx.compiler.d.ts ├── extensions.d.ts ├── index.d.ts ├── vscode-proposed │ ├── index.d.ts │ ├── vscode.proposed.quickPickItemTooltip.d.ts │ └── vscode.proposed.saveEditor.d.ts └── webworker.fix.d.ts └── vscode.d.ts /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16-slim 2 | # WORKDIR /app 3 | # COPY . /app 4 | # RUN npm install 5 | # EXPOSE 3000 6 | # CMD ["node", "index.js"] 7 | 8 | # # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.227.0/containers/javascript-node/.devcontainer/base.Dockerfile 9 | 10 | # # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster 11 | # ARG VARIANT="16-bullseye" 12 | # FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} 13 | 14 | # # [Optional] Uncomment this section to install additional OS packages. 15 | # # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 16 | # # && apt-get -y install --no-install-recommends 17 | 18 | # # [Optional] Uncomment if you want to install an additional version of node using nvm 19 | # # ARG EXTRA_NODE_VERSION=10 20 | # # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" 21 | 22 | # # [Optional] Uncomment if you want to install more global node modules 23 | # # RUN su node -c "npm install -g " 24 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.227.0/containers/javascript-node 3 | { 4 | "name": "Node.js", 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | // Update 'VARIANT' to pick a Node version: 16, 14, 12. 8 | // Append -bullseye or -buster to pin to an OS version. 9 | // Use -bullseye variants on local arm64/Apple Silicon. 10 | // "args": { "VARIANT": "16" } 11 | }, 12 | 13 | // Set *default* container specific settings.json values on container create. 14 | "settings": {}, 15 | 16 | // Add the IDs of extensions you want installed when the container is created. 17 | "extensions": [ 18 | "dbaeumer.vscode-eslint" 19 | ], 20 | 21 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 22 | // "forwardPorts": [], 23 | 24 | // Use 'postCreateCommand' to run commands after the container is created. 25 | // "postCreateCommand": "yarn install", 26 | 27 | // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. 28 | "remoteUser": "node" 29 | } 30 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Tab indentation 7 | [*] 8 | indent_style = space 9 | indent_size = 4 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | # The indent size used in the `package.json` file cannot be changed 14 | # https://github.com/npm/npm/pull/3180#issuecomment-16336516 15 | [{.travis.yml,npm-shrinkwrap.json,package.json}] 16 | indent_style = space 17 | indent_size = 4 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | package.json text eol=lf 2 | package-lock.json text eol=lf 3 | requirements.txt text eol=lf 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3_feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Request for the Python extension, not supporting/sibling extensions 4 | labels: classify, feature-request 5 | --- 6 | 7 | 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 'Bug 🐜' 4 | url: https://aka.ms/pvsc-bug 5 | about: 'Use the `Python: Report Issue...` command (follow the link for instructions)' 6 | - name: 'Pylance' 7 | url: https://github.com/microsoft/pylance-release/issues 8 | about: 'For issues relating to the Pylance language server extension' 9 | - name: 'Jupyter' 10 | url: https://github.com/microsoft/vscode-jupyter/issues 11 | about: 'For issues relating to the Jupyter extension (including the interactive window)' 12 | - name: 'Debugpy' 13 | url: https://github.com/microsoft/debugpy/issues 14 | about: 'For issues relating to the debugpy debugger' 15 | - name: Help/Support 16 | url: https://github.com/microsoft/vscode-python/discussions/categories/q-a 17 | about: 'Having trouble with the extension? Need help getting something to work?' 18 | -------------------------------------------------------------------------------- /.github/actions/lint/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lint' 2 | description: 'Lint TypeScript and Python code' 3 | 4 | inputs: 5 | node_version: 6 | description: 'Version of Node to install' 7 | required: true 8 | 9 | runs: 10 | using: 'composite' 11 | steps: 12 | - name: Install Node 13 | uses: actions/setup-node@v3 14 | with: 15 | node-version: ${{ inputs.node_version }} 16 | cache: 'npm' 17 | 18 | - name: Install Node dependencies 19 | run: npm ci --prefer-offline 20 | shell: bash 21 | 22 | - name: Run `gulp prePublishNonBundle` 23 | run: npx gulp prePublishNonBundle 24 | shell: bash 25 | 26 | - name: Check dependencies 27 | run: npm run checkDependencies 28 | shell: bash 29 | 30 | - name: Lint TypeScript code 31 | run: npm run lint 32 | shell: bash 33 | 34 | - name: Check TypeScript format 35 | run: npm run format-check 36 | shell: bash 37 | 38 | - name: Install Python 39 | uses: actions/setup-python@v4 40 | with: 41 | python-version: '3.x' 42 | cache: 'pip' 43 | 44 | - name: Check Python format 45 | run: | 46 | python -m pip install -U black 47 | python -m black . --check 48 | working-directory: pythonFiles 49 | shell: bash 50 | 51 | - name: Run Ruff 52 | run: | 53 | python -m pip install -U ruff 54 | python -m ruff check . 55 | working-directory: pythonFiles 56 | shell: bash 57 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: 'github-actions' 4 | directory: / 5 | schedule: 6 | interval: daily 7 | labels: 8 | - 'no-changelog' 9 | 10 | - package-ecosystem: 'github-actions' 11 | directory: .github/actions/build-vsix 12 | schedule: 13 | interval: daily 14 | labels: 15 | - 'no-changelog' 16 | 17 | - package-ecosystem: 'github-actions' 18 | directory: .github/actions/lint 19 | schedule: 20 | interval: daily 21 | labels: 22 | - 'no-changelog' 23 | 24 | - package-ecosystem: 'github-actions' 25 | directory: .github/actions/smoke-test 26 | schedule: 27 | interval: daily 28 | labels: 29 | - 'no-changelog' 30 | 31 | # Not skipping the news for some Python dependencies in case it's actually useful to communicate to users. 32 | - package-ecosystem: 'pip' 33 | directory: / 34 | schedule: 35 | interval: daily 36 | ignore: 37 | - dependency-name: prospector # Due to Python 2.7 and #14477. 38 | - dependency-name: pytest # Due to Python 2.7 and #13776. 39 | - dependency-name: py # Due to Python 2.7. 40 | - dependency-name: isort 41 | - dependency-name: jedi-language-server 42 | labels: 43 | - 'no-changelog' 44 | # Activate when we feel ready to keep up with frequency. 45 | # - package-ecosystem: 'npm' 46 | # directory: / 47 | # schedule: 48 | # interval: daily 49 | # default_labels: 50 | # - "no-changelog" 51 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - 'no-changelog' 5 | authors: 6 | - 'dependabot' 7 | 8 | categories: 9 | - title: Enhancements 10 | labels: 11 | - 'feature-request' 12 | 13 | - title: Bug Fixes 14 | labels: 15 | - 'bug' 16 | 17 | - title: Code Health 18 | labels: 19 | - 'debt' 20 | -------------------------------------------------------------------------------- /.github/workflows/community-feedback-auto-comment.yml: -------------------------------------------------------------------------------- 1 | name: Community Feedback Auto Comment 2 | 3 | on: 4 | issues: 5 | types: 6 | - labeled 7 | jobs: 8 | add-comment: 9 | if: github.event.label.name == 'needs community feedback' 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write 13 | steps: 14 | - name: Check For Existing Comment 15 | uses: peter-evans/find-comment@v2 16 | id: finder 17 | with: 18 | issue-number: ${{ github.event.issue.number }} 19 | comment-author: 'github-actions[bot]' 20 | body-includes: 'Thanks for the feature request! We are going to give the community' 21 | 22 | - name: Add Community Feedback Comment 23 | if: steps.finder.outputs.comment-id == '' 24 | uses: peter-evans/create-or-update-comment@v3 25 | with: 26 | issue-number: ${{ github.event.issue.number }} 27 | body: | 28 | Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue. 29 | -------------------------------------------------------------------------------- /.github/workflows/getLabels.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To run this file: 3 | * * npm install @octokit/rest 4 | * * node .github/workflows/getLabels.js 5 | * 6 | * This script assumes the maximum number of labels to be 100. 7 | */ 8 | 9 | const { Octokit } = require('@octokit/rest'); 10 | const github = new Octokit(); 11 | github.rest.issues 12 | .listLabelsForRepo({ 13 | owner: 'microsoft', 14 | repo: 'vscode-python', 15 | per_page: 100, 16 | }) 17 | .then((result) => { 18 | const labels = result.data.map((label) => label.name); 19 | console.log( 20 | '\nNumber of labels found:', 21 | labels.length, 22 | ", verify that it's the same as number of labels listed in https://github.com/microsoft/vscode-python/labels\n", 23 | ); 24 | console.log(JSON.stringify(labels), '\n'); 25 | }); 26 | -------------------------------------------------------------------------------- /.github/workflows/info-needed-closer.yml: -------------------------------------------------------------------------------- 1 | name: Info-Needed Closer 2 | on: 3 | schedule: 4 | - cron: 20 12 * * * # 5:20am Redmond 5 | repository_dispatch: 6 | types: [trigger-needs-more-info] 7 | workflow_dispatch: 8 | 9 | jobs: 10 | main: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout Actions 14 | uses: actions/checkout@v4 15 | with: 16 | repository: 'microsoft/vscode-github-triage-actions' 17 | path: ./actions 18 | ref: stable 19 | - name: Install Actions 20 | run: npm install --production --prefix ./actions 21 | - name: Run info-needed Closer 22 | uses: ./actions/needs-more-info-closer 23 | with: 24 | label: info-needed 25 | closeDays: 30 26 | closeComment: "Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off. \n\nHappy Coding!" 27 | pingDays: 30 28 | pingComment: "Hey @${assignee}, this issue might need further attention.\n\n@${author}, you can help us out by closing this issue if the problem no longer exists, or adding more information." 29 | -------------------------------------------------------------------------------- /.github/workflows/lock-issues.yml: -------------------------------------------------------------------------------- 1 | name: 'Lock Issues' 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | issues: write 10 | 11 | concurrency: 12 | group: lock 13 | 14 | jobs: 15 | lock-issues: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: 'Lock Issues' 19 | uses: dessant/lock-threads@v4 20 | with: 21 | github-token: ${{ github.token }} 22 | issue-inactive-days: '30' 23 | process-only: 'issues' 24 | log-output: true 25 | -------------------------------------------------------------------------------- /.github/workflows/pr-labels.yml: -------------------------------------------------------------------------------- 1 | name: 'PR labels' 2 | on: 3 | pull_request: 4 | types: 5 | - 'opened' 6 | - 'reopened' 7 | - 'labeled' 8 | - 'unlabeled' 9 | - 'synchronize' 10 | 11 | jobs: 12 | classify: 13 | name: 'Classify PR' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: 'PR impact specified' 17 | uses: mheap/github-action-required-labels@v5 18 | with: 19 | mode: exactly 20 | count: 1 21 | labels: 'bug, debt, feature-request, no-changelog' 22 | -------------------------------------------------------------------------------- /.github/workflows/python27-issue-response.yml: -------------------------------------------------------------------------------- 1 | on: 2 | issues: 3 | types: [opened] 4 | 5 | jobs: 6 | python27-issue-response: 7 | runs-on: ubuntu-latest 8 | if: "contains(github.event.issue.body, 'Python version (& distribution if applicable, e.g. Anaconda): 2.7')" 9 | steps: 10 | - name: Check for Python 2.7 string 11 | run: | 12 | response="We're sorry, but we no longer support Python 2.7. If you need to work with Python 2.7, you will have to pin to 2022.2.* version of the extension, which was the last version that had the debugger (debugpy) with support for python 2.7, and was tested with `2.7`. Thank you for your understanding! \n ![https://user-images.githubusercontent.com/51720070/80000627-39dacc00-8472-11ea-9755-ac7ba0acbb70.gif](https://user-images.githubusercontent.com/51720070/80000627-39dacc00-8472-11ea-9755-ac7ba0acbb70.gif)" 13 | gh issue comment ${{ github.event.issue.number }} --body "$response" 14 | gh issue close ${{ github.event.issue.number }} 15 | -------------------------------------------------------------------------------- /.github/workflows/remove-needs-labels.yml: -------------------------------------------------------------------------------- 1 | name: 'Remove Needs Label' 2 | on: 3 | issues: 4 | types: [closed] 5 | 6 | jobs: 7 | classify: 8 | name: 'Remove needs labels on issue closing' 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: 'Removes needs labels on issue close' 12 | uses: actions-ecosystem/action-remove-labels@v1 13 | with: 14 | labels: | 15 | needs PR 16 | needs spike 17 | needs community feedback 18 | needs proposal 19 | -------------------------------------------------------------------------------- /.github/workflows/test-plan-item-validator.yml: -------------------------------------------------------------------------------- 1 | name: Test Plan Item Validator 2 | on: 3 | issues: 4 | types: [edited, labeled] 5 | 6 | permissions: 7 | issues: write 8 | 9 | jobs: 10 | main: 11 | runs-on: ubuntu-latest 12 | if: contains(github.event.issue.labels.*.name, 'testplan-item') || contains(github.event.issue.labels.*.name, 'invalid-testplan-item') 13 | steps: 14 | - name: Checkout Actions 15 | uses: actions/checkout@v4 16 | with: 17 | repository: 'microsoft/vscode-github-triage-actions' 18 | path: ./actions 19 | ref: stable 20 | 21 | - name: Install Actions 22 | run: npm install --production --prefix ./actions 23 | 24 | - name: Run Test Plan Item Validator 25 | uses: ./actions/test-plan-item-validator 26 | with: 27 | label: testplan-item 28 | invalidLabel: invalid-testplan-item 29 | comment: Invalid test plan item. See errors below and the [test plan item spec](https://github.com/microsoft/vscode/wiki/Writing-Test-Plan-Items) for more information. This comment will go away when the issues are resolved. 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .huskyrc.json 3 | out 4 | log.log 5 | **/node_modules 6 | *.pyc 7 | *.vsix 8 | **/.vscode/.ropeproject/** 9 | **/testFiles/**/.cache/** 10 | *.noseids 11 | .nyc_output 12 | .vscode-test 13 | __pycache__ 14 | npm-debug.log 15 | **/.mypy_cache/** 16 | !yarn.lock 17 | coverage/ 18 | cucumber-report.json 19 | **/.vscode-test/** 20 | **/.vscode test/** 21 | **/.vscode-smoke/** 22 | **/.venv*/ 23 | port.txt 24 | precommit.hook 25 | pythonFiles/lib/** 26 | pythonFiles/get-pip.py 27 | debug_coverage*/** 28 | languageServer/** 29 | languageServer.*/** 30 | bin/** 31 | obj/** 32 | .pytest_cache 33 | tmp/** 34 | .python-version 35 | .vs/ 36 | test-results*.xml 37 | xunit-test-results.xml 38 | build/ci/performance/performance-results.json 39 | !build/ 40 | debug*.log 41 | debugpy*.log 42 | pydevd*.log 43 | nodeLanguageServer/** 44 | nodeLanguageServer.*/** 45 | dist/** 46 | # translation files 47 | *.xlf 48 | package.nls.*.json 49 | l10n/ 50 | vscode.d.ts 51 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | @types:registry=https://registry.npmjs.org 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v16.13.0 2 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | singleQuote: true, 3 | printWidth: 120, 4 | tabWidth: 4, 5 | endOfLine: 'auto', 6 | trailingComma: 'all', 7 | overrides: [ 8 | { 9 | files: ['*.yml', '*.yaml'], 10 | options: { 11 | tabWidth: 2 12 | } 13 | } 14 | ] 15 | }; 16 | -------------------------------------------------------------------------------- /.sonarcloud.properties: -------------------------------------------------------------------------------- 1 | sonar.sources=src/client 2 | sonar.tests=src/test 3 | sonar.cfamily.build-wrapper-output.bypass=true 4 | sonar.cpd.exclusions=src/client/activation/**/*.ts 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "editorconfig.editorconfig", 6 | "esbenp.prettier-vscode", 7 | "dbaeumer.vscode-eslint", 8 | "ms-python.python", 9 | "ms-python.black-formatter", 10 | "ms-python.vscode-pylance" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceFolder}"], 11 | "smartStep": true, 12 | "sourceMaps": true, 13 | "outFiles": ["${workspaceFolder}/out/**/*", "!${workspaceFolder}/**/node_modules**/*"], 14 | "skipFiles": ["/**"], 15 | "env": { 16 | "VSC_PYTHON_FORCE_LOGGING": "1", 17 | // Enable this to try out new experiments locally 18 | "VSC_PYTHON_LOAD_EXPERIMENTS_FROM_FILE": "1", 19 | // Enable this to log telemetry to the output during debugging 20 | "XVSC_PYTHON_LOG_TELEMETRY": "1", 21 | // Enable this to log debugger output. Directory must exist ahead of time 22 | "XDEBUGPY_LOG_DIR": "${workspaceRoot}/tmp/Debug_Output_Ex" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "presentation": { 4 | "echo": true, 5 | "reveal": "always", 6 | "focus": false, 7 | "panel": "shared" 8 | }, 9 | "tasks": [ 10 | { 11 | "label": "Compile", 12 | "type": "npm", 13 | "script": "compile", 14 | "isBackground": true, 15 | "problemMatcher": [ 16 | "$tsc-watch" 17 | ], 18 | "group": { 19 | "kind": "build", 20 | "isDefault": true 21 | } 22 | }, 23 | { 24 | "label": "Run Unit Tests", 25 | "type": "npm", 26 | "script": "test:unittests", 27 | "group": { 28 | "kind": "test", 29 | "isDefault": true 30 | } 31 | }, 32 | { 33 | "type": "npm", 34 | "script": "preTestJediLSP", 35 | "problemMatcher": [], 36 | "label": "preTestJediLSP" 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | **/*.map 2 | **/*.analyzer.html 3 | *.vsix 4 | .editorconfig 5 | .env 6 | .eslintrc 7 | .gitattributes 8 | .gitignore 9 | .gitmodules 10 | .npmrc 11 | .nvmrc 12 | .nycrc 13 | CODE_OF_CONDUCT.md 14 | CODING_STANDARDS.md 15 | CONTRIBUTING.md 16 | gulpfile.js 17 | package-lock.json 18 | requirements.in 19 | sprint-planning.github-issues 20 | test.ipynb 21 | tsconfig*.json 22 | tsfmt.json 23 | vscode-python-signing.* 24 | 25 | .github/** 26 | .mocha-reporter/** 27 | .nvm/** 28 | .nyc_output 29 | .prettierrc.js 30 | .sonarcloud.properties 31 | .venv/** 32 | .vscode/** 33 | .vscode-test/** 34 | .vscode test/** 35 | languageServer/** 36 | languageServer.*/** 37 | nodeLanguageServer/** 38 | nodeLanguageServer.*/** 39 | bin/** 40 | build/** 41 | BuildOutput/** 42 | coverage/** 43 | data/** 44 | debug_coverage*/** 45 | images/**/*.gif 46 | images/**/*.png 47 | ipywidgets/** 48 | i18n/** 49 | node_modules/** 50 | obj/** 51 | out/**/*.stats.json 52 | out/client/**/*.analyzer.html 53 | out/coverconfig.json 54 | out/pythonFiles/** 55 | out/src/** 56 | out/test/** 57 | out/testMultiRootWkspc/** 58 | precommit.hook 59 | pythonFiles/**/*.pyc 60 | pythonFiles/lib/**/*.egg-info/** 61 | pythonFiles/lib/python/bin/** 62 | pythonFiles/jedilsp_requirements/** 63 | pythonFiles/tests/** 64 | scripts/** 65 | src/** 66 | test/** 67 | tmp/** 68 | typings/** 69 | types/** 70 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/CONTRIBUTING.md -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Don Jayamanne. All rights reserved. 2 | 3 | MIT Don Jayamanne 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/.mocha-multi-reporters.config: -------------------------------------------------------------------------------- 1 | { 2 | "reporterEnabled": "./build/ci/scripts/spec_with_pid,mocha-junit-reporter" 3 | } 4 | -------------------------------------------------------------------------------- /build/.mocha.functional.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec": "./out/test/**/*.functional.test.js", 3 | "require": [ 4 | "out/test/unittests.js" 5 | ], 6 | "exclude": "out/**/*.jsx", 7 | "reporter": "mocha-multi-reporters", 8 | "reporter-option": "configFile=./build/.mocha-multi-reporters.config", 9 | "ui": "tdd", 10 | "recursive": true, 11 | "colors": true, 12 | "exit": true, 13 | "timeout": 180000 14 | } 15 | -------------------------------------------------------------------------------- /build/.mocha.functional.perf.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec": "./out/test/**/*.functional.test.js", 3 | "exclude-out": "out/**/*.jsx", 4 | "require": ["out/test/unittests.js"], 5 | "reporter": "spec", 6 | "ui": "tdd", 7 | "recursive": true, 8 | "colors": true, 9 | "exit": true, 10 | "timeout": 180000 11 | } 12 | -------------------------------------------------------------------------------- /build/.mocha.perf.config: -------------------------------------------------------------------------------- 1 | { 2 | "reporterEnabled": "spec,xunit", 3 | "xunitReporterOptions": { 4 | "output": "xunit-test-results.xml" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /build/.mocha.performance.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec": "./out/test/**/*.functional.test.js", 3 | "require": ["out/test/unittests.js"], 4 | "reporter": "mocha-multi-reporters", 5 | "reporter-option": "configFile=build/.mocha.perf.config", 6 | "ui": "tdd", 7 | "recursive": true, 8 | "colors": true, 9 | "exit": true, 10 | "timeout": 30000 11 | } 12 | -------------------------------------------------------------------------------- /build/.mocha.unittests.js.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec": "./out/test/**/*.unit.test.js", 3 | "require": ["source-map-support/register", "out/test/unittests.js"], 4 | "reporter": "mocha-multi-reporters", 5 | "reporter-option": "configFile=build/.mocha-multi-reporters.config", 6 | "ui": "tdd", 7 | "recursive": true, 8 | "colors": true 9 | } 10 | -------------------------------------------------------------------------------- /build/.mocha.unittests.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec": "./out/test/**/*.unit.test.js", 3 | "require": [ 4 | "out/test/unittests.js" 5 | ], 6 | "exclude": "out/**/*.jsx", 7 | "reporter": "mocha-multi-reporters", 8 | "reporter-option": "configFile=./build/.mocha-multi-reporters.config", 9 | "ui": "tdd", 10 | "recursive": true, 11 | "colors": true, 12 | "timeout": 180000 13 | } 14 | -------------------------------------------------------------------------------- /build/.mocha.unittests.ts.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec": "./src/test/**/*.unit.test.ts", 3 | "require": ["ts-node/register", "out/test/unittests.js"], 4 | "reporter": "mocha-multi-reporters", 5 | "reporter-option": "configFile=build/.mocha-multi-reporters.config", 6 | "ui": "tdd", 7 | "recursive": true, 8 | "colors": true 9 | } 10 | -------------------------------------------------------------------------------- /build/.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@istanbuljs/nyc-config-typescript", 3 | "all": true, 4 | "include": [ 5 | "src/client/**/*.ts", "out/client/**/*.js" 6 | ], 7 | "exclude": ["src/test/**/*.ts", "out/test/**/*.js"], 8 | "exclude-node-modules": true 9 | } 10 | -------------------------------------------------------------------------------- /build/azure-pipelines/templates/pack-steps.yml: -------------------------------------------------------------------------------- 1 | ############################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See License.txt in the project root for license information. 4 | ############################################################################################### 5 | parameters: 6 | - name: package 7 | 8 | steps: 9 | - script: npm install --root-only 10 | workingDirectory: $(Build.SourcesDirectory) 11 | displayName: Install root dependencies 12 | - script: npm install 13 | workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} 14 | displayName: Install package dependencies 15 | -------------------------------------------------------------------------------- /build/azure-pipelines/templates/test-steps.yml: -------------------------------------------------------------------------------- 1 | ############################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See License.txt in the project root for license information. 4 | ############################################################################################### 5 | parameters: 6 | - name: package 7 | type: string 8 | - name: script 9 | type: string 10 | default: 'all:publish' 11 | 12 | steps: 13 | - script: npm install --root-only 14 | workingDirectory: $(Build.SourcesDirectory) 15 | displayName: Install root dependencies 16 | - bash: | 17 | /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & 18 | echo ">>> Started xvfb" 19 | displayName: Start xvfb 20 | condition: eq(variables['Agent.OS'], 'Linux') 21 | - script: npm run ${{ parameters.script }} 22 | workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} 23 | displayName: Verify package 24 | -------------------------------------------------------------------------------- /build/build-install-requirements.txt: -------------------------------------------------------------------------------- 1 | # Requirements needed to run install_debugpy.py and download_get_pip.py 2 | packaging 3 | -------------------------------------------------------------------------------- /build/ci/addEnvPath.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | #Adds the virtual environment's executable path to json file 5 | 6 | import json,sys 7 | import os.path 8 | jsonPath = sys.argv[1] 9 | key = sys.argv[2] 10 | 11 | if os.path.isfile(jsonPath): 12 | with open(jsonPath, 'r') as read_file: 13 | data = json.load(read_file) 14 | else: 15 | directory = os.path.dirname(jsonPath) 16 | if not os.path.exists(directory): 17 | os.makedirs(directory) 18 | with open(jsonPath, 'w+') as read_file: 19 | data = {} 20 | data = {} 21 | with open(jsonPath, 'w') as outfile: 22 | if key == 'condaExecPath': 23 | data[key] = sys.argv[3] 24 | else: 25 | data[key] = sys.executable 26 | json.dump(data, outfile, sort_keys=True, indent=4) 27 | -------------------------------------------------------------------------------- /build/ci/conda_base.yml: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /build/ci/conda_env_1.yml: -------------------------------------------------------------------------------- 1 | name: conda_env_1 2 | dependencies: 3 | - python=3.7 4 | - pip 5 | -------------------------------------------------------------------------------- /build/ci/conda_env_2.yml: -------------------------------------------------------------------------------- 1 | name: conda_env_2 2 | dependencies: 3 | - python=3.8 4 | - pip 5 | -------------------------------------------------------------------------------- /build/ci/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "poetry-tutorial-project" 3 | version = "0.1.0" 4 | description = "" 5 | authors = [""] 6 | 7 | [tool.poetry.dependencies] 8 | python = "*" 9 | -------------------------------------------------------------------------------- /build/ci/static_analysis/policheck/exceptions.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/build/ci/static_analysis/policheck/exceptions.mdb -------------------------------------------------------------------------------- /build/constants.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | const util = require('./util'); 7 | 8 | exports.ExtensionRootDir = util.ExtensionRootDir; 9 | // This is a list of files that existed before MS got the extension. 10 | exports.existingFiles = util.getListOfFiles('existingFiles.json'); 11 | exports.contributedFiles = util.getListOfFiles('contributedFiles.json'); 12 | exports.isWindows = /^win/.test(process.platform); 13 | exports.isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined; 14 | -------------------------------------------------------------------------------- /build/contributedFiles.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /build/fail.js: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | process.exitCode = 1; 7 | -------------------------------------------------------------------------------- /build/functional-test-requirements.txt: -------------------------------------------------------------------------------- 1 | # List of requirements for functional tests 2 | versioneer 3 | numpy 4 | -------------------------------------------------------------------------------- /build/license-header.txt: -------------------------------------------------------------------------------- 1 | PLEASE NOTE: This is the license for the Python extension for Visual Studio Code. The Python extension automatically installs other extensions as optional dependencies, which can be uninstalled at any time. These extensions have separate licenses: 2 | 3 | - The Jupyter extension is released under an MIT License: 4 | https://marketplace.visualstudio.com/items/ms-toolsai.jupyter/license 5 | 6 | - The Pylance extension is only available in binary form and is released under a Microsoft proprietary license, the terms of which are available here: 7 | https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license 8 | 9 | ------------------------------------------------------------------------------ 10 | -------------------------------------------------------------------------------- /build/test-requirements.txt: -------------------------------------------------------------------------------- 1 | # pin setoptconf to prevent issue with 'use_2to3' 2 | setoptconf==0.3.0 3 | 4 | # Install flake8 first, as both flake8 and autopep8 require pycodestyle, 5 | # but flake8 has a tighter pinning. 6 | flake8 7 | autopep8 8 | bandit 9 | black 10 | yapf 11 | pylint 12 | pycodestyle 13 | pydocstyle 14 | prospector 15 | pytest 16 | flask 17 | fastapi 18 | uvicorn 19 | django 20 | isort 21 | 22 | # Integrated TensorBoard tests 23 | tensorboard 24 | torch-tb-profiler 25 | 26 | # extension build tests 27 | freezegun 28 | -------------------------------------------------------------------------------- /build/unlocalizedFiles.json: -------------------------------------------------------------------------------- 1 | [ 2 | "src/client/activation/activationService.ts", 3 | "src/client/common/installer/channelManager.ts", 4 | "src/client/common/installer/moduleInstaller.ts", 5 | "src/client/common/installer/productInstaller.ts", 6 | "src/client/debugger/extension/hooks/childProcessAttachService.ts", 7 | "src/client/formatters/baseFormatter.ts", 8 | "src/client/formatters/blackFormatter.ts", 9 | "src/client/interpreter/configuration/pythonPathUpdaterService.ts", 10 | "src/client/linters/errorHandlers/notInstalled.ts", 11 | "src/client/linters/errorHandlers/standard.ts", 12 | "src/client/linters/linterCommands.ts", 13 | "src/client/linters/prospector.ts", 14 | "src/client/providers/importSortProvider.ts", 15 | "src/client/providers/objectDefinitionProvider.ts", 16 | "src/client/providers/simpleRefactorProvider.ts", 17 | "src/client/pythonEnvironments/discovery/locators/services/pipEnvService.ts", 18 | "src/client/terminals/codeExecution/helper.ts", 19 | "src/client/testing/common/debugLauncher.ts", 20 | "src/client/testing/common/managers/baseTestManager.ts", 21 | "src/client/testing/common/services/discovery.ts", 22 | "src/client/testing/configuration.ts", 23 | "src/client/testing/display/main.ts", 24 | "src/client/testing/main.ts", 25 | "src/client/workspaceSymbols/generator.ts" 26 | ] 27 | -------------------------------------------------------------------------------- /build/update_package_file.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import json 5 | import pathlib 6 | 7 | EXT_ROOT = pathlib.Path(__file__).parent.parent 8 | PACKAGE_JSON_PATH = EXT_ROOT / "package.json" 9 | 10 | 11 | def main(package_json: pathlib.Path) -> None: 12 | package = json.loads(package_json.read_text(encoding="utf-8")) 13 | package["enableTelemetry"] = True 14 | 15 | # Overwrite package.json with new data add a new-line at the end of the file. 16 | package_json.write_text( 17 | json.dumps(package, indent=4, ensure_ascii=False) + "\n", encoding="utf-8" 18 | ) 19 | 20 | 21 | if __name__ == "__main__": 22 | main(PACKAGE_JSON_PATH) 23 | -------------------------------------------------------------------------------- /build/util.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | const fs = require('fs'); 7 | const path = require('path'); 8 | 9 | exports.ExtensionRootDir = path.dirname(__dirname); 10 | function getListOfFiles(filename) { 11 | filename = path.normalize(filename); 12 | if (!path.isAbsolute(filename)) { 13 | filename = path.join(__dirname, filename); 14 | } 15 | const data = fs.readFileSync(filename).toString(); 16 | const files = JSON.parse(data); 17 | return files.map((file) => path.join(exports.ExtensionRootDir, file.replace(/\//g, path.sep))); 18 | } 19 | exports.getListOfFiles = getListOfFiles; 20 | -------------------------------------------------------------------------------- /build/webpack/loaders/externalizeDependencies.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | const common = require('../common'); 5 | 6 | function replaceModule(prefixRegex, prefix, contents, moduleName, quotes) { 7 | const stringToSearch = `${prefixRegex}${quotes}${moduleName}${quotes}`; 8 | const stringToReplaceWith = `${prefix}${quotes}./node_modules/${moduleName}${quotes}`; 9 | return contents.replace(new RegExp(stringToSearch, 'gm'), stringToReplaceWith); 10 | } 11 | 12 | // eslint-disable-next-line camelcase 13 | function default_1(source) { 14 | common.nodeModulesToReplacePaths.forEach((moduleName) => { 15 | if (source.indexOf(moduleName) > 0) { 16 | source = replaceModule('import\\(', 'import(', source, moduleName, '"'); 17 | source = replaceModule('import\\(', 'import(', source, moduleName, "'"); 18 | source = replaceModule('require\\(', 'require(', source, moduleName, '"'); 19 | source = replaceModule('require\\(', 'require(', source, moduleName, "'"); 20 | source = replaceModule('from ', 'from ', source, moduleName, '"'); 21 | source = replaceModule('from ', 'from ', source, moduleName, "'"); 22 | } 23 | }); 24 | return source; 25 | } 26 | // eslint-disable-next-line camelcase 27 | exports.default = default_1; 28 | -------------------------------------------------------------------------------- /build/webpack/loaders/jsonloader.js: -------------------------------------------------------------------------------- 1 | // For some reason this has to be in commonjs format 2 | 3 | module.exports = function (source) { 4 | // Just inline the source and fix up defaults so that they don't 5 | // mess up the logic in the setOptions.js file 6 | return `module.exports = ${source}\nmodule.exports.default = false`; 7 | }; 8 | -------------------------------------------------------------------------------- /build/webpack/loaders/remarkLoader.js: -------------------------------------------------------------------------------- 1 | // For some reason this has to be in commonjs format 2 | 3 | module.exports = function (source) { 4 | // Just inline the source and fix up defaults so that they don't 5 | // mess up the logic in the setOptions.js file 6 | return `module.exports = ${source}\nmodule.exports.default = false`; 7 | }; 8 | -------------------------------------------------------------------------------- /build/webpack/nativeOrInteractivePicker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Click here to Open Native Editor
6 | Click here to Open Interactive Window 7 | 8 | 9 | -------------------------------------------------------------------------------- /build/webpack/webpack.extension.dependencies.config.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | const copyWebpackPlugin = require('copy-webpack-plugin'); 7 | const path = require('path'); 8 | const constants = require('../constants'); 9 | const common = require('./common'); 10 | 11 | const entryItems = {}; 12 | common.nodeModulesToExternalize.forEach((moduleName) => { 13 | entryItems[`node_modules/${moduleName}`] = `./node_modules/${moduleName}`; 14 | }); 15 | const config = { 16 | mode: 'production', 17 | target: 'node', 18 | context: constants.ExtensionRootDir, 19 | entry: entryItems, 20 | devtool: 'source-map', 21 | node: { 22 | __dirname: false, 23 | }, 24 | module: {}, 25 | externals: ['vscode', 'commonjs'], 26 | plugins: [ 27 | ...common.getDefaultPlugins('dependencies'), 28 | // vsls requires our package.json to be next to node_modules. It's how they 29 | // 'find' the calling extension. 30 | // eslint-disable-next-line new-cap 31 | new copyWebpackPlugin({ patterns: [{ from: './package.json', to: '.' }] }), 32 | ], 33 | resolve: { 34 | extensions: ['.js'], 35 | }, 36 | output: { 37 | filename: '[name].js', 38 | path: path.resolve(constants.ExtensionRootDir, 'out', 'client'), 39 | libraryTarget: 'commonjs2', 40 | devtoolModuleFilenameTemplate: '../../[resource-path]', 41 | }, 42 | }; 43 | 44 | exports.default = config; 45 | -------------------------------------------------------------------------------- /cgmanifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "Registrations": [ 3 | { 4 | "Component": { 5 | "Other": { 6 | "Name": "get-pip", 7 | "Version": "21.3.1", 8 | "DownloadUrl": "https://github.com/pypa/get-pip" 9 | }, 10 | "Type": "other" 11 | }, 12 | "DevelopmentDependency": false 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /data/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "xpython.defaultInterpreterPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /data/test.py: -------------------------------------------------------------------------------- 1 | #%% 2 | print('hello') 3 | -------------------------------------------------------------------------------- /images/activeWorkspaceEnv.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/images/activeWorkspaceEnv.mp4 -------------------------------------------------------------------------------- /images/createEnvs.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/images/createEnvs.mp4 -------------------------------------------------------------------------------- /images/createVenv.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/images/createVenv.mp4 -------------------------------------------------------------------------------- /images/managePackages.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/images/managePackages.mp4 -------------------------------------------------------------------------------- /images/workspaceEnvs.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/images/workspaceEnvs.mp4 -------------------------------------------------------------------------------- /images/workspaceEnvs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/images/workspaceEnvs.png -------------------------------------------------------------------------------- /pythonFiles/.env: -------------------------------------------------------------------------------- 1 | PYTHONPATH=./lib/python 2 | -------------------------------------------------------------------------------- /pythonFiles/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/__pycache__/**": true, 4 | "**/**/*.pyc": true 5 | }, 6 | "python.formatting.provider": "black" 7 | } 8 | -------------------------------------------------------------------------------- /pythonFiles/create_microvenv.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | import subprocess 8 | import sys 9 | from typing import Optional, Sequence 10 | 11 | VENV_NAME = ".venv" 12 | LIB_ROOT = pathlib.Path(__file__).parent / "lib" / "python" 13 | CWD = pathlib.Path.cwd() 14 | 15 | 16 | class MicroVenvError(Exception): 17 | pass 18 | 19 | 20 | def run_process(args: Sequence[str], error_message: str) -> None: 21 | try: 22 | print("Running: " + " ".join(args)) 23 | subprocess.run(args, cwd=os.getcwd(), check=True) 24 | except subprocess.CalledProcessError: 25 | raise MicroVenvError(error_message) 26 | 27 | 28 | def parse_args(argv: Sequence[str]) -> argparse.Namespace: 29 | parser = argparse.ArgumentParser() 30 | 31 | parser.add_argument( 32 | "--name", 33 | default=VENV_NAME, 34 | type=str, 35 | help="Name of the virtual environment.", 36 | metavar="NAME", 37 | action="store", 38 | ) 39 | return parser.parse_args(argv) 40 | 41 | 42 | def create_microvenv(name: str): 43 | run_process( 44 | [sys.executable, os.fspath(LIB_ROOT / "microvenv.py"), name], 45 | "CREATE_MICROVENV.MICROVENV_FAILED_CREATION", 46 | ) 47 | 48 | 49 | def main(argv: Optional[Sequence[str]] = None) -> None: 50 | if argv is None: 51 | argv = [] 52 | args = parse_args(argv) 53 | 54 | print("CREATE_MICROVENV.CREATING_MICROVENV") 55 | create_microvenv(args.name) 56 | print("CREATE_MICROVENV.CREATED_MICROVENV") 57 | 58 | 59 | if __name__ == "__main__": 60 | main(sys.argv[1:]) 61 | -------------------------------------------------------------------------------- /pythonFiles/download_get_pip.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import json 5 | import os 6 | import pathlib 7 | import urllib.request as url_lib 8 | from packaging.version import parse as version_parser 9 | 10 | EXTENSION_ROOT = pathlib.Path(__file__).parent.parent 11 | GET_PIP_DEST = EXTENSION_ROOT / "pythonFiles" 12 | PIP_PACKAGE = "pip" 13 | PIP_VERSION = "latest" # Can be "latest", or specific version "23.1.2" 14 | 15 | 16 | def _get_package_data(): 17 | json_uri = "https://pypi.org/pypi/{0}/json".format(PIP_PACKAGE) 18 | # Response format: https://warehouse.readthedocs.io/api-reference/json/#project 19 | # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst 20 | with url_lib.urlopen(json_uri) as response: 21 | return json.loads(response.read()) 22 | 23 | 24 | def _download_and_save(root, version): 25 | root = os.getcwd() if root is None or root == "." else root 26 | url = f"https://raw.githubusercontent.com/pypa/get-pip/{version}/public/get-pip.py" 27 | print(url) 28 | with url_lib.urlopen(url) as response: 29 | data = response.read() 30 | get_pip_file = pathlib.Path(root) / "get-pip.py" 31 | get_pip_file.write_bytes(data) 32 | 33 | 34 | def main(root): 35 | data = _get_package_data() 36 | 37 | if PIP_VERSION == "latest": 38 | use_version = max(data["releases"].keys(), key=version_parser) 39 | else: 40 | use_version = PIP_VERSION 41 | 42 | _download_and_save(root, use_version) 43 | 44 | 45 | if __name__ == "__main__": 46 | main(GET_PIP_DEST) 47 | -------------------------------------------------------------------------------- /pythonFiles/get_output_via_markers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import runpy 5 | import sys 6 | 7 | # Sometimes executing scripts can print out stuff before the actual output is 8 | # printed. For eg. when activating conda. Hence, printing out markers to make 9 | # it more resilient to pull the output. 10 | print(">>>PYTHON-EXEC-OUTPUT") 11 | 12 | module = sys.argv[1] 13 | try: 14 | if module == "-c": 15 | ns = {} 16 | code = sys.argv[2] 17 | del sys.argv[2] 18 | del sys.argv[0] 19 | exec(code, ns, ns) 20 | elif module.startswith("-m"): 21 | moduleName = sys.argv[2] 22 | sys.argv = sys.argv[2:] # It should begin with the module name. 23 | runpy.run_module(moduleName, run_name="__main__", alter_sys=True) 24 | elif module.endswith(".py"): 25 | sys.argv = sys.argv[1:] 26 | runpy.run_path(module, run_name="__main__") 27 | elif module.startswith("-"): 28 | raise NotImplementedError(sys.argv) 29 | else: 30 | runpy.run_module(module, run_name="__main__", alter_sys=True) 31 | finally: 32 | print("<< 2**32 12 | 13 | print(json.dumps(obj)) 14 | -------------------------------------------------------------------------------- /pythonFiles/jedilsp_requirements/requirements.in: -------------------------------------------------------------------------------- 1 | # This file is used to generate requirements.txt. 2 | # To update requirements.txt, run the following commands. 3 | # Use Python 3.7 when creating the environment or using pip-tools 4 | # 1) pip install pip-tools 5 | # 2) pip-compile --generate-hashes --upgrade pythonFiles\jedilsp_requirements\requirements.in 6 | 7 | jedi-language-server>=0.34.3 8 | pygls>=0.10.3 9 | -------------------------------------------------------------------------------- /pythonFiles/linter.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | 4 | 5 | linter_settings = { 6 | "pylint": { 7 | "args": ["--reports=n", "--output-format=json"], 8 | }, 9 | "flake8": { 10 | "args": ["--format", "%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s"], 11 | }, 12 | "bandit": { 13 | "args": [ 14 | "-f", 15 | "custom", 16 | "--msg-template", 17 | "{line},{col},{severity},{test_id}:{msg}", 18 | "-n", 19 | "-1", 20 | ], 21 | }, 22 | "mypy": {"args": []}, 23 | "prospector": { 24 | "args": ["--absolute-paths", "--output-format=json"], 25 | }, 26 | "pycodestyle": { 27 | "args": ["--format", "%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s"], 28 | }, 29 | "pydocstyle": { 30 | "args": [], 31 | }, 32 | "pylama": {"args": ["--format=parsable"]}, 33 | } 34 | 35 | 36 | def main(): 37 | invoke = sys.argv[1] 38 | if invoke == "-m": 39 | linter = sys.argv[2] 40 | args = ( 41 | [sys.executable, "-m", linter] 42 | + linter_settings[linter]["args"] 43 | + sys.argv[3:] 44 | ) 45 | else: 46 | linter = sys.argv[2] 47 | args = [sys.argv[3]] + linter_settings[linter]["args"] + sys.argv[4:] 48 | 49 | if hasattr(subprocess, "run"): 50 | subprocess.run(args, encoding="utf-8", stdout=sys.stdout, stderr=sys.stderr) 51 | else: 52 | subprocess.call(args, stdout=sys.stdout, stderr=sys.stderr) 53 | 54 | 55 | if __name__ == "__main__": 56 | main() 57 | -------------------------------------------------------------------------------- /pythonFiles/printEnvVariables.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | import json 6 | 7 | print(json.dumps(dict(os.environ))) 8 | -------------------------------------------------------------------------------- /pythonFiles/printEnvVariablesToFile.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | import json 6 | import sys 7 | 8 | 9 | # Last argument is the target file into which we'll write the env variables as json. 10 | json_file = sys.argv[-1] 11 | 12 | with open(json_file, "w") as outfile: 13 | json.dump(dict(os.environ), outfile) 14 | -------------------------------------------------------------------------------- /pythonFiles/run-jedi-language-server.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | # Add the lib path to our sys path so jedi_language_server can find its references 5 | EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 6 | sys.path.insert(0, os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "jedilsp")) 7 | 8 | 9 | from jedi_language_server.cli import cli 10 | 11 | sys.exit(cli()) 12 | -------------------------------------------------------------------------------- /pythonFiles/shell_exec.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import subprocess 5 | import sys 6 | 7 | # This is a simple solution to waiting for completion of commands sent to terminal. 8 | # 1. Intercept commands send to a terminal 9 | # 2. Send commands to our script file with an additional argument 10 | # 3. In here create a file that'll log the progress. 11 | # 4. Calling code monitors the contents of the file to determine state of execution. 12 | 13 | # Last argument is a file that's used for synchronizing the actions in the terminal with the calling code in extension. 14 | lock_file = sys.argv[-1] 15 | shell_args = sys.argv[1:-1] 16 | 17 | print("Executing command in shell >> " + " ".join(shell_args)) 18 | 19 | with open(lock_file, "w") as fp: 20 | try: 21 | # Signal start of execution. 22 | fp.write("START\n") 23 | fp.flush() 24 | 25 | subprocess.check_call(shell_args, stdout=sys.stdout, stderr=sys.stderr) 26 | 27 | # Signal start of execution. 28 | fp.write("END\n") 29 | fp.flush() 30 | except Exception: 31 | import traceback 32 | 33 | print(traceback.format_exc()) 34 | # Signal end of execution with failure state. 35 | fp.write("FAIL\n") 36 | fp.flush() 37 | try: 38 | # ALso log the error for use from the other side. 39 | with open(lock_file + ".error", "w") as fpError: 40 | fpError.write(traceback.format_exc()) 41 | except Exception: 42 | pass 43 | -------------------------------------------------------------------------------- /pythonFiles/tensorboard_launcher.py: -------------------------------------------------------------------------------- 1 | import time 2 | import sys 3 | import os 4 | import mimetypes 5 | from tensorboard import program 6 | 7 | 8 | def main(logdir): 9 | # Environment variable for PyTorch profiler TensorBoard plugin 10 | # to detect when it's running inside VS Code 11 | os.environ["VSCODE_TENSORBOARD_LAUNCH"] = "1" 12 | 13 | # Work around incorrectly configured MIME types on Windows 14 | mimetypes.add_type("application/javascript", ".js") 15 | 16 | # Start TensorBoard using their Python API 17 | tb = program.TensorBoard() 18 | tb.configure(bind_all=False, logdir=logdir) 19 | url = tb.launch() 20 | sys.stdout.write("TensorBoard started at %s\n" % (url)) 21 | sys.stdout.flush() 22 | 23 | while True: 24 | try: 25 | time.sleep(60) 26 | except KeyboardInterrupt: 27 | break 28 | sys.stdout.write("TensorBoard is shutting down") 29 | sys.stdout.flush() 30 | 31 | 32 | if __name__ == "__main__": 33 | if len(sys.argv) == 2: 34 | logdir = str(sys.argv[1]) 35 | sys.stdout.write("Starting TensorBoard with logdir %s" % (logdir)) 36 | main(logdir) 37 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/adapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/adapter/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class UnsupportedToolError(ValueError): 6 | def __init__(self, tool): 7 | msg = "unsupported tool {!r}".format(tool) 8 | super(UnsupportedToolError, self).__init__(msg) 9 | self.tool = tool 10 | 11 | 12 | class UnsupportedCommandError(ValueError): 13 | def __init__(self, cmd): 14 | msg = "unsupported cmd {!r}".format(cmd) 15 | super(UnsupportedCommandError, self).__init__(msg) 16 | self.cmd = cmd 17 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/adapter/pytest/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from __future__ import absolute_import 5 | 6 | from ._cli import add_subparser as add_cli_subparser # noqa: F401 7 | from ._discovery import discover # noqa: F401 8 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/adapter/pytest/_cli.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from __future__ import absolute_import 5 | 6 | from ..errors import UnsupportedCommandError 7 | 8 | 9 | def add_subparser(cmd, name, parent): 10 | """Add a new subparser to the given parent and add args to it.""" 11 | parser = parent.add_parser(name) 12 | if cmd == "discover": 13 | # For now we don't have any tool-specific CLI options to add. 14 | pass 15 | else: 16 | raise UnsupportedCommandError(cmd) 17 | return parser 18 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/process_json_util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import io 4 | import json 5 | from typing import List 6 | 7 | CONTENT_LENGTH: str = "Content-Length:" 8 | 9 | 10 | def process_rpc_json(data: str) -> List[str]: 11 | """Process the JSON data which comes from the server.""" 12 | str_stream: io.StringIO = io.StringIO(data) 13 | 14 | length: int = 0 15 | 16 | while True: 17 | line: str = str_stream.readline() 18 | if CONTENT_LENGTH.lower() in line.lower(): 19 | length = int(line[len(CONTENT_LENGTH) :]) 20 | break 21 | 22 | if not line or line.isspace(): 23 | raise ValueError("Header does not contain Content-Length") 24 | 25 | while True: 26 | line: str = str_stream.readline() 27 | if not line or line.isspace(): 28 | break 29 | 30 | raw_json: str = str_stream.read(length) 31 | return json.loads(raw_json) 32 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/run_adapter.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | # Replace the "." entry. 5 | import os.path 6 | import sys 7 | 8 | sys.path.insert( 9 | 1, 10 | os.path.dirname( # pythonFiles 11 | os.path.dirname( # pythonFiles/testing_tools 12 | os.path.abspath(__file__) # this file 13 | ) 14 | ), 15 | ) 16 | 17 | from testing_tools.adapter.__main__ import parse_args, main 18 | 19 | 20 | if __name__ == "__main__": 21 | tool, cmd, subargs, toolargs = parse_args() 22 | main(tool, cmd, subargs, toolargs) 23 | -------------------------------------------------------------------------------- /pythonFiles/testing_tools/socket_manager.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import socket 5 | import sys 6 | 7 | 8 | class SocketManager(object): 9 | """Create a socket and connect to the given address. 10 | 11 | The address is a (host: str, port: int) tuple. 12 | Example usage: 13 | 14 | ``` 15 | with SocketManager(("localhost", 6767)) as sock: 16 | request = json.dumps(payload) 17 | result = s.socket.sendall(request.encode("utf-8")) 18 | ``` 19 | """ 20 | 21 | def __init__(self, addr): 22 | self.addr = addr 23 | self.socket = None 24 | 25 | def __enter__(self): 26 | self.socket = socket.socket( 27 | socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP 28 | ) 29 | if sys.platform == "win32": 30 | addr_use = socket.SO_EXCLUSIVEADDRUSE 31 | else: 32 | addr_use = socket.SO_REUSEADDR 33 | self.socket.setsockopt(socket.SOL_SOCKET, addr_use, 1) 34 | self.socket.connect(self.addr) 35 | 36 | return self 37 | 38 | def __exit__(self, *_): 39 | if self.socket: 40 | try: 41 | self.socket.shutdown(socket.SHUT_RDWR) 42 | except Exception: 43 | pass 44 | self.socket.close() 45 | -------------------------------------------------------------------------------- /pythonFiles/testlauncher.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def parse_argv(): 9 | """Parses arguments for use with the test launcher. 10 | Arguments are: 11 | 1. Working directory. 12 | 2. Test runner `pytest` 13 | 3. Rest of the arguments are passed into the test runner. 14 | """ 15 | cwd = sys.argv[1] 16 | testRunner = sys.argv[2] 17 | args = sys.argv[3:] 18 | 19 | return (cwd, testRunner, args) 20 | 21 | 22 | def run(cwd, testRunner, args): 23 | """Runs the test 24 | cwd -- the current directory to be set 25 | testRunner -- test runner to be used `pytest` 26 | args -- arguments passed into the test runner 27 | """ 28 | 29 | sys.path[0] = os.getcwd() 30 | os.chdir(cwd) 31 | 32 | try: 33 | if testRunner == "pytest": 34 | import pytest 35 | 36 | pytest.main(args) 37 | sys.exit(0) 38 | finally: 39 | pass 40 | 41 | 42 | if __name__ == "__main__": 43 | cwd, testRunner, args = parse_argv() 44 | run(cwd, testRunner, args) 45 | -------------------------------------------------------------------------------- /pythonFiles/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import os.path 4 | 5 | TEST_ROOT = os.path.dirname(__file__) 6 | SRC_ROOT = os.path.dirname(TEST_ROOT) 7 | PROJECT_ROOT = os.path.dirname(SRC_ROOT) 8 | TESTING_TOOLS_ROOT = os.path.join(SRC_ROOT, "testing_tools") 9 | DEBUG_ADAPTER_ROOT = os.path.join(SRC_ROOT, "debug_adapter") 10 | 11 | PYTHONFILES = os.path.join(SRC_ROOT, "lib", "python") 12 | -------------------------------------------------------------------------------- /pythonFiles/tests/debug_adapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/debug_adapter/test_install_debugpy.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pytest 3 | import subprocess 4 | import sys 5 | 6 | 7 | def _check_binaries(dir_path): 8 | expected_endswith = ( 9 | "win_amd64.pyd", 10 | "win32.pyd", 11 | "darwin.so", 12 | "i386-linux-gnu.so", 13 | "x86_64-linux-gnu.so", 14 | ) 15 | 16 | binaries = list(p for p in os.listdir(dir_path) if p.endswith(expected_endswith)) 17 | 18 | assert len(binaries) == len(expected_endswith) 19 | 20 | 21 | @pytest.mark.skipif( 22 | sys.version_info[:2] != (3, 7), 23 | reason="DEBUGPY wheels shipped for Python 3.7 only", 24 | ) 25 | def test_install_debugpy(tmpdir): 26 | import install_debugpy 27 | 28 | install_debugpy.main(str(tmpdir)) 29 | dir_path = os.path.join( 30 | str(tmpdir), "debugpy", "_vendored", "pydevd", "_pydevd_bundle" 31 | ) 32 | _check_binaries(dir_path) 33 | 34 | dir_path = os.path.join( 35 | str(tmpdir), "debugpy", "_vendored", "pydevd", "_pydevd_frame_eval" 36 | ) 37 | _check_binaries(dir_path) 38 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/nested_folder_one/test_bottom_folder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | # This test's id is dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_t. 6 | # This test passes. 7 | def test_bottom_function_t(): # test_marker--test_bottom_function_t 8 | assert True 9 | 10 | 11 | # This test's id is dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_f. 12 | # This test fails. 13 | def test_bottom_function_f(): # test_marker--test_bottom_function_f 14 | assert False 15 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/test_top_folder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | # This test's id is dual_level_nested_folder/test_top_folder.py::test_top_function_t. 6 | # This test passes. 7 | def test_top_function_t(): # test_marker--test_top_function_t 8 | assert True 9 | 10 | 11 | # This test's id is dual_level_nested_folder/test_top_folder.py::test_top_function_f. 12 | # This test fails. 13 | def test_top_function_f(): # test_marker--test_top_function_f 14 | assert False 15 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/empty_discovery.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | # This file has no tests in it; the discovery will return an empty list of tests. 6 | def function_function(string): 7 | return string 8 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/error_parametrize_discovery.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import pytest 4 | 5 | 6 | # This test has an error which will appear on pytest discovery. 7 | # This error is intentional and is meant to test pytest discovery error handling. 8 | @pytest.mark.parametrize("actual,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)]) 9 | def test_function(): 10 | assert True 11 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/error_pytest_import.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | @pytest.mark.parametrize("num", range(1, 89)) 5 | def test_odd_even(num): 6 | assert True 7 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/error_raise_exception.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import pytest 5 | 6 | 7 | @pytest.fixture 8 | def raise_fixture(): 9 | raise Exception("Dummy exception") 10 | 11 | 12 | class TestSomething: 13 | def test_a(self, raise_fixture): 14 | assert True 15 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/error_syntax_discovery.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | # This test has a syntax error. 5 | # This error is intentional and is meant to test pytest discovery error handling. 6 | def test_function() 7 | assert True 8 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/folder_a/folder_b/folder_a/test_nest.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | # This test's id is double_nested_folder/nested_folder_one/nested_folder_two/test_nest.py::test_function. 6 | # This test passes. 7 | def test_function(): # test_marker--test_function 8 | assert 1 == 1 9 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/param_same_name/test_param1.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import pytest 4 | 5 | 6 | @pytest.mark.parametrize("num", ["a", "b", "c"]) 7 | def test_odd_even(num): 8 | assert True 9 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/param_same_name/test_param2.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import pytest 4 | 5 | 6 | @pytest.mark.parametrize("num", range(1, 4)) 7 | def test_odd_even(num): 8 | assert True 9 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/parametrize_tests.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import pytest 5 | 6 | 7 | # Testing pytest with parametrized tests. The first two pass, the third fails. 8 | # The tests ids are parametrize_tests.py::test_adding[3+5-8] and so on. 9 | @pytest.mark.parametrize( # test_marker--test_adding 10 | "actual, expected", [("3+5", 8), ("2+4", 6), ("6+9", 16)] 11 | ) 12 | def test_adding(actual, expected): 13 | assert eval(actual) == expected 14 | 15 | 16 | # Testing pytest with parametrized tests. All three pass. 17 | # The tests ids are parametrize_tests.py::test_under_ten[1] and so on. 18 | @pytest.mark.parametrize("num", range(1, 3)) # test_marker--test_under_ten 19 | def test_under_ten(num): 20 | assert num < 10 21 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/root/tests/pytest.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/pytestadapter/.data/root/tests/pytest.ini -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/root/tests/test_a.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | def test_a_function(): # test_marker--test_a_function 6 | assert True 7 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/root/tests/test_b.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | def test_b_function(): # test_marker--test_b_function 6 | assert True 7 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/simple_pytest.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | # This test passes. 6 | def test_function(): # test_marker--test_function 7 | assert 1 == 1 8 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/skip_tests.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import pytest 5 | 6 | # Testing pytest with skipped tests. The first passes, the second three are skipped. 7 | 8 | 9 | def test_something(): # test_marker--test_something 10 | # This tests passes successfully. 11 | assert 1 + 1 == 2 12 | 13 | 14 | def test_another_thing(): # test_marker--test_another_thing 15 | # Skip this test with a reason. 16 | pytest.skip("Skipping this test for now") 17 | 18 | 19 | @pytest.mark.skip( 20 | reason="Skipping this test as it requires additional setup" # test_marker--test_complex_thing 21 | ) 22 | def test_decorator_thing(): 23 | # Skip this test as well, with a reason. This one uses a decorator. 24 | assert True 25 | 26 | 27 | @pytest.mark.skipif(1 < 5, reason="is always true") # test_marker--test_complex_thing_2 28 | def test_decorator_thing_2(): 29 | # Skip this test as well, with a reason. This one uses a decorator with a condition. 30 | assert True 31 | 32 | 33 | # With this test, the entire class is skipped. 34 | @pytest.mark.skip(reason="Skip TestClass") 35 | class TestClass: 36 | def test_class_function_a(self): # test_marker--test_class_function_a 37 | assert True 38 | 39 | def test_class_function_b(self): # test_marker--test_class_function_b 40 | assert False 41 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/text_docstring.txt: -------------------------------------------------------------------------------- 1 | This is a doctest test which passes #test_marker--text_docstring.txt 2 | >>> x = 3 3 | >>> x 4 | 3 5 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/unittest_folder/test_add.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | 6 | def add(a, b): 7 | return a + b 8 | 9 | 10 | class TestAddFunction(unittest.TestCase): 11 | # This test's id is unittest_folder/test_add.py::TestAddFunction::test_add_positive_numbers. 12 | # This test passes. 13 | def test_add_positive_numbers(self): # test_marker--test_add_positive_numbers 14 | result = add(2, 3) 15 | self.assertEqual(result, 5) 16 | 17 | # This test's id is unittest_folder/test_add.py::TestAddFunction::test_add_negative_numbers. 18 | # This test passes. 19 | def test_add_negative_numbers(self): # test_marker--test_add_negative_numbers 20 | result = add(-2, -3) 21 | self.assertEqual(result, -5) 22 | 23 | 24 | class TestDuplicateFunction(unittest.TestCase): 25 | # This test's id is unittest_folder/test_subtract.py::TestDuplicateFunction::test_dup_a. It has the same class name as 26 | # another test, but it's in a different file, so it should not be confused. 27 | # This test passes. 28 | def test_dup_a(self): # test_marker--test_dup_a 29 | self.assertEqual(1, 1) 30 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/unittest_folder/test_subtract.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | 6 | def subtract(a, b): 7 | return a - b 8 | 9 | 10 | class TestSubtractFunction(unittest.TestCase): 11 | # This test's id is unittest_folder/test_subtract.py::TestSubtractFunction::test_subtract_positive_numbers. 12 | # This test passes. 13 | def test_subtract_positive_numbers( # test_marker--test_subtract_positive_numbers 14 | self, 15 | ): 16 | result = subtract(5, 3) 17 | self.assertEqual(result, 2) 18 | 19 | # This test's id is unittest_folder/test_subtract.py::TestSubtractFunction::test_subtract_negative_numbers. 20 | # This test passes. 21 | def test_subtract_negative_numbers( # test_marker--test_subtract_negative_numbers 22 | self, 23 | ): 24 | result = subtract(-2, -3) 25 | # This is intentional to test assertion failures 26 | self.assertEqual(result, 100000) 27 | 28 | 29 | class TestDuplicateFunction(unittest.TestCase): 30 | # This test's id is unittest_folder/test_subtract.py::TestDuplicateFunction::test_dup_s. It has the same class name as 31 | # another test, but it's in a different file, so it should not be confused. 32 | # This test passes. 33 | def test_dup_s(self): # test_marker--test_dup_s 34 | self.assertEqual(1, 1) 35 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/unittest_pytest_same_file.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class TestExample(unittest.TestCase): 8 | # This test's id is unittest_pytest_same_file.py::TestExample::test_true_unittest. 9 | # Test type is unittest and this test passes. 10 | def test_true_unittest(self): # test_marker--test_true_unittest 11 | assert True 12 | 13 | 14 | # This test's id is unittest_pytest_same_file.py::test_true_pytest. 15 | # Test type is pytest and this test passes. 16 | def test_true_pytest(): # test_marker--test_true_pytest 17 | assert True 18 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/.data/unittest_skiptest_file_level.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | from unittest import SkipTest 6 | 7 | # Due to the skip at the file level, no tests will be discovered. 8 | raise SkipTest("Skip all tests in this file, they should not be recognized by pytest.") 9 | 10 | 11 | class SimpleTest(unittest.TestCase): 12 | def testadd1(self): 13 | assert True 14 | -------------------------------------------------------------------------------- /pythonFiles/tests/pytestadapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/run_all.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | # Replace the "." entry. 5 | import os.path 6 | import sys 7 | 8 | sys.path[0] = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 9 | 10 | from tests.__main__ import main, parse_args 11 | 12 | 13 | if __name__ == "__main__": 14 | mainkwargs, pytestargs = parse_args() 15 | ec = main(pytestargs, **mainkwargs) 16 | sys.exit(ec) 17 | -------------------------------------------------------------------------------- /pythonFiles/tests/test_create_microvenv.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import importlib 5 | import os 6 | import sys 7 | 8 | import create_microvenv 9 | 10 | 11 | def test_create_microvenv(): 12 | importlib.reload(create_microvenv) 13 | run_process_called = False 14 | 15 | def run_process(args, error_message): 16 | nonlocal run_process_called 17 | run_process_called = True 18 | assert args == [ 19 | sys.executable, 20 | os.fspath(create_microvenv.LIB_ROOT / "microvenv.py"), 21 | create_microvenv.VENV_NAME, 22 | ] 23 | assert error_message == "CREATE_MICROVENV.MICROVENV_FAILED_CREATION" 24 | 25 | create_microvenv.run_process = run_process 26 | 27 | create_microvenv.main() 28 | assert run_process_called is True 29 | -------------------------------------------------------------------------------- /pythonFiles/tests/test_data/no-missing-deps.data: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile with Python 3.7 3 | # by the following command: 4 | # 5 | # pip-compile --generate-hashes --resolver=backtracking requirements-test.in 6 | # 7 | pytest==7.3.1 \ 8 | --hash=sha256:3799fa815351fea3a5e96ac7e503a96fa51cc9942c3753cda7651b93c1cfa362 \ 9 | --hash=sha256:434afafd78b1d78ed0addf160ad2b77a30d35d4bdf8af234fe621919d9ed15e3 10 | 11 | tomli==2.0.1 \ 12 | --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ 13 | --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f 14 | -------------------------------------------------------------------------------- /pythonFiles/tests/test_data/pyproject-missing-deps.data: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["flit_core >=3.2,<4"] 3 | build-backend = "flit_core.buildapi" 4 | 5 | [project] 6 | name = "something" 7 | version = "2023.0.0" 8 | requires-python = ">=3.7" 9 | dependencies = ["pytest==7.3.1", "flake8-csv"] 10 | -------------------------------------------------------------------------------- /pythonFiles/tests/test_data/pyproject-no-missing-deps.data: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["flit_core >=3.2,<4"] 3 | build-backend = "flit_core.buildapi" 4 | 5 | [project] 6 | name = "something" 7 | version = "2023.0.0" 8 | requires-python = ">=3.7" 9 | dependencies = [jedi-language-server"] 10 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/C/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/C/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/C/test_Spam.py: -------------------------------------------------------------------------------- 1 | 2 | def test_okay(): 3 | assert True 4 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/mod.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | Examples: 4 | 5 | >>> square(1) 6 | 1 7 | >>> square(2) 8 | 4 9 | >>> square(3) 10 | 9 11 | >>> spam = Spam() 12 | >>> spam.eggs() 13 | 42 14 | """ 15 | 16 | 17 | def square(x): 18 | """ 19 | 20 | Examples: 21 | 22 | >>> square(1) 23 | 1 24 | >>> square(2) 25 | 4 26 | >>> square(3) 27 | 9 28 | """ 29 | return x * x 30 | 31 | 32 | class Spam(object): 33 | """ 34 | 35 | Examples: 36 | 37 | >>> spam = Spam() 38 | >>> spam.eggs() 39 | 42 40 | """ 41 | 42 | def eggs(self): 43 | """ 44 | 45 | Examples: 46 | 47 | >>> spam = Spam() 48 | >>> spam.eggs() 49 | 42 50 | """ 51 | return 42 52 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/spam.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(): 3 | assert True 4 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_42-43.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(): 3 | assert True 4 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_42.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(): 3 | assert True 4 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_doctest.py: -------------------------------------------------------------------------------- 1 | """ 2 | Doctests: 3 | 4 | >>> 1 == 1 5 | True 6 | """ 7 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_doctest.txt: -------------------------------------------------------------------------------- 1 | 2 | assignment & lookup: 3 | 4 | >>> x = 3 5 | >>> x 6 | 3 7 | 8 | deletion: 9 | 10 | >>> del x 11 | >>> x 12 | Traceback (most recent call last): 13 | ... 14 | NameError: name 'x' is not defined 15 | 16 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_foo.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def test_simple(): 4 | assert True 5 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_mixed.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import unittest 3 | 4 | 5 | def test_top_level(): 6 | assert True 7 | 8 | 9 | @pytest.mark.skip 10 | def test_skipped(): 11 | assert False 12 | 13 | 14 | class TestMySuite(object): 15 | 16 | def test_simple(self): 17 | assert True 18 | 19 | 20 | class MyTests(unittest.TestCase): 21 | 22 | def test_simple(self): 23 | assert True 24 | 25 | @pytest.mark.skip 26 | def test_skipped(self): 27 | assert False 28 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/test_pytest_param.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | # module-level parameterization 5 | pytestmark = pytest.mark.parametrize('x', [(1,), (1.0,), (1+0j,)]) 6 | 7 | 8 | def test_param_13(x): 9 | assert x == 1 10 | 11 | 12 | class TestParamAll(object): 13 | 14 | def test_param_13(self, x): 15 | assert x == 1 16 | 17 | def test_spam_13(self, x): 18 | assert x == 1 19 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/testspam.py: -------------------------------------------------------------------------------- 1 | ''' 2 | ... 3 | ... 4 | ... 5 | ''' 6 | 7 | 8 | def test_simple(): 9 | assert True 10 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/v/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/v/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/v/spam.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(self): 3 | assert True 4 | 5 | 6 | class TestSimple(object): 7 | 8 | def test_simple(self): 9 | assert True 10 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/v/test_eggs.py: -------------------------------------------------------------------------------- 1 | from .spam import * 2 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/v/test_ham.py: -------------------------------------------------------------------------------- 1 | from .spam import test_simple 2 | from .spam import test_simple as test_not_hard 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/v/test_spam.py: -------------------------------------------------------------------------------- 1 | from .spam import test_simple 2 | 3 | 4 | def test_simpler(self): 5 | assert True 6 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/w/test_spam.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | def test_simple(): 5 | assert True 6 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/w/test_spam_ex.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | def test_simple(): 5 | assert True 6 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/a/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/a/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/a/test_spam.py: -------------------------------------------------------------------------------- 1 | """ 2 | ... 3 | """ 4 | 5 | 6 | # ... 7 | 8 | ANSWER = 42 9 | 10 | 11 | def test_simple(): 12 | assert True 13 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/b/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/b/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/b/test_spam.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ?!? 4 | CHORUS = 'spamspamspamspamspam...' 5 | 6 | 7 | def test_simple(): 8 | assert True 9 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/complex/tests/x/y/z/test_ham.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(): 3 | assert True 4 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/notests/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/notests/tests/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/simple/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/simple/tests/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/simple/tests/test_spam.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(): 3 | assert True 4 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/syntax-error/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/pythonFiles/tests/testing_tools/adapter/.data/syntax-error/tests/__init__.py -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/.data/syntax-error/tests/test_spam.py: -------------------------------------------------------------------------------- 1 | 2 | def test_simple(): 3 | assert True 4 | 5 | 6 | # A syntax error: 7 | : 8 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/testing_tools/adapter/pytest/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/discovery_empty.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class DiscoveryEmpty(unittest.TestCase): 8 | """Test class for the test_empty_discovery test. 9 | 10 | The discover_tests function should return a dictionary with a "success" status, no errors, and no test tree 11 | if unittest discovery was performed successfully but no tests were found. 12 | """ 13 | 14 | def something(self) -> bool: 15 | return True 16 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/discovery_error/file_one.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | import something_else # type: ignore # noqa: F401 7 | 8 | 9 | class DiscoveryErrorOne(unittest.TestCase): 10 | """Test class for the test_error_discovery test. 11 | 12 | The discover_tests function should return a dictionary with an "error" status, the discovered tests, and a list of errors 13 | if unittest discovery failed at some point. 14 | """ 15 | 16 | def test_one(self) -> None: 17 | self.assertGreater(2, 1) 18 | 19 | def test_two(self) -> None: 20 | self.assertNotEqual(2, 1) 21 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/discovery_error/file_two.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class DiscoveryErrorTwo(unittest.TestCase): 8 | """Test class for the test_error_discovery test. 9 | 10 | The discover_tests function should return a dictionary with an "error" status, the discovered tests, and a list of errors 11 | if unittest discovery failed at some point. 12 | """ 13 | 14 | def test_one(self) -> None: 15 | self.assertGreater(2, 1) 16 | 17 | def test_two(self) -> None: 18 | self.assertNotEqual(2, 1) 19 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/discovery_simple.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class DiscoverySimple(unittest.TestCase): 8 | """Test class for the test_simple_discovery test. 9 | 10 | The discover_tests function should return a dictionary with a "success" status, no errors, and a test tree 11 | if unittest discovery was performed successfully. 12 | """ 13 | 14 | def test_one(self) -> None: 15 | self.assertGreater(2, 1) 16 | 17 | def test_two(self) -> None: 18 | self.assertNotEqual(2, 1) 19 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/test_fail_simple.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | # Test class for the test_fail_simple test. 7 | # The test_failed_tests function should return a dictionary with a "success" status 8 | # and the two tests with their outcome as "failed". 9 | 10 | class RunFailSimple(unittest.TestCase): 11 | """Test class for the test_fail_simple test. 12 | 13 | The test_failed_tests function should return a dictionary with a "success" status 14 | and the two tests with their outcome as "failed". 15 | """ 16 | 17 | def test_one_fail(self) -> None: 18 | self.assertGreater(2, 3) 19 | 20 | def test_two_fail(self) -> None: 21 | self.assertNotEqual(1, 1) 22 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/test_subtest.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | # Test class for the test_subtest_run test. 7 | # The test_failed_tests function should return a dictionary that has a "success" status 8 | # and the "result" value is a dict with 6 entries, one for each subtest. 9 | 10 | 11 | class NumbersTest(unittest.TestCase): 12 | def test_even(self): 13 | """ 14 | Test that numbers between 0 and 5 are all even. 15 | """ 16 | for i in range(0, 6): 17 | with self.subTest(i=i): 18 | self.assertEqual(i % 2, 0) 19 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/test_two_classes.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | # Test class which runs for the test_multiple_ids_run test with the two class parameters. 7 | # Both test functions will be returned in a dictionary with a "success" status, 8 | # and the two tests with their outcome as "success". 9 | 10 | 11 | class ClassOne(unittest.TestCase): 12 | 13 | def test_one(self) -> None: 14 | self.assertGreater(2, 1) 15 | 16 | class ClassTwo(unittest.TestCase): 17 | 18 | def test_two(self) -> None: 19 | self.assertGreater(2, 1) 20 | 21 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/two_patterns/pattern_a_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | # Test class for the two file pattern test. It is pattern *test.py. 6 | # The test_ids_multiple_runs function should return a dictionary with a "success" status, 7 | # and the two tests with their outcome as "success". 8 | 9 | 10 | 11 | class DiscoveryA(unittest.TestCase): 12 | """Test class for the two file pattern test. It is pattern *test.py 13 | 14 | The test_ids_multiple_runs function should return a dictionary with a "success" status, 15 | and the two tests with their outcome as "success". 16 | """ 17 | 18 | def test_one_a(self) -> None: 19 | self.assertGreater(2, 1) 20 | 21 | def test_two_a(self) -> None: 22 | self.assertNotEqual(2, 1) -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/two_patterns/test_pattern_b.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | # Test class for the two file pattern test. This file is pattern test*.py. 6 | # The test_ids_multiple_runs function should return a dictionary with a "success" status, 7 | # and the two tests with their outcome as "success". 8 | 9 | class DiscoveryB(unittest.TestCase): 10 | 11 | def test_one_b(self) -> None: 12 | self.assertGreater(2, 1) 13 | 14 | def test_two_b(self) -> None: 15 | self.assertNotEqual(2, 1) -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/unittest_folder/test_add.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | # Test class which runs for the test_multiple_ids_run test with the two test 6 | # files in the same folder. The cwd is set to the parent folder. This should return 7 | # a dictionary with a "success" status and the two tests with their outcome as "success". 8 | 9 | def add(a, b): 10 | return a + b 11 | 12 | 13 | class TestAddFunction(unittest.TestCase): 14 | 15 | def test_add_positive_numbers(self): 16 | result = add(2, 3) 17 | self.assertEqual(result, 5) 18 | 19 | 20 | def test_add_negative_numbers(self): 21 | result = add(-2, -3) 22 | self.assertEqual(result, -5) -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/unittest_folder/test_subtract.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | # Test class which runs for the test_multiple_ids_run test with the two test 6 | # files in the same folder. The cwd is set to the parent folder. This should return 7 | # a dictionary with a "success" status and the two tests with their outcome as "success". 8 | 9 | def subtract(a, b): 10 | return a - b 11 | 12 | 13 | class TestSubtractFunction(unittest.TestCase): 14 | def test_subtract_positive_numbers(self): 15 | result = subtract(5, 3) 16 | self.assertEqual(result, 2) 17 | 18 | 19 | def test_subtract_negative_numbers(self): 20 | result = subtract(-2, -3) 21 | self.assertEqual(result, 1) -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/unittest_skip/unittest_skip_file.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from unittest import SkipTest 5 | 6 | raise SkipTest("This is unittest.SkipTest calling") 7 | 8 | 9 | def test_example(): 10 | assert 1 == 1 11 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/unittest_skip/unittest_skip_function.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | def add(x, y): 8 | return x + y 9 | 10 | 11 | class SimpleTest(unittest.TestCase): 12 | @unittest.skip("demonstrating skipping") 13 | def testadd1(self): 14 | self.assertEquals(add(4, 5), 9) 15 | 16 | 17 | if __name__ == "__main__": 18 | unittest.main() 19 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/utils_decorated_tree.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | from functools import wraps 6 | 7 | 8 | def my_decorator(f): 9 | @wraps(f) 10 | def wrapper(*args, **kwds): 11 | print("Calling decorated function") 12 | return f(*args, **kwds) 13 | 14 | return wrapper 15 | 16 | 17 | class TreeOne(unittest.TestCase): 18 | """Test class for the test_build_decorated_tree test. 19 | 20 | build_test_tree should build a test tree with these test cases. 21 | """ 22 | 23 | @my_decorator 24 | def test_one(self) -> None: 25 | self.assertGreater(2, 1) 26 | 27 | @my_decorator 28 | def test_two(self) -> None: 29 | self.assertNotEqual(2, 1) 30 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/utils_nested_cases/file_one.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class CaseTwoFileOne(unittest.TestCase): 8 | """Test class for the test_nested_test_cases test. 9 | 10 | get_test_case should return tests from the test suites in this folder. 11 | """ 12 | 13 | def test_one(self) -> None: 14 | self.assertGreater(2, 1) 15 | 16 | def test_two(self) -> None: 17 | self.assertNotEqual(2, 1) 18 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/utils_nested_cases/folder/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/utils_nested_cases/folder/file_two.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class CaseTwoFileTwo(unittest.TestCase): 8 | """Test class for the test_nested_test_cases test. 9 | 10 | get_test_case should return tests from the test suites in this folder. 11 | """ 12 | 13 | def test_one(self) -> None: 14 | self.assertGreater(2, 1) 15 | 16 | def test_two(self) -> None: 17 | self.assertNotEqual(2, 1) 18 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/utils_simple_cases.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class CaseOne(unittest.TestCase): 8 | """Test class for the test_simple_test_cases test. 9 | 10 | get_test_case should return tests from the test suite. 11 | """ 12 | 13 | def test_one(self) -> None: 14 | self.assertGreater(2, 1) 15 | 16 | def test_two(self) -> None: 17 | self.assertNotEqual(2, 1) 18 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/.data/utils_simple_tree.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | 7 | class TreeOne(unittest.TestCase): 8 | """Test class for the test_build_simple_tree test. 9 | 10 | build_test_tree should build a test tree with these test cases. 11 | """ 12 | 13 | def test_one(self) -> None: 14 | self.assertGreater(2, 1) 15 | 16 | def test_two(self) -> None: 17 | self.assertNotEqual(2, 1) 18 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/conftest.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import sys 5 | 6 | # Ignore the contents of this folder for Python 2 tests. 7 | if sys.version_info[0] < 3: 8 | collect_ignore_glob = ["*.py"] 9 | -------------------------------------------------------------------------------- /pythonFiles/tests/unittestadapter/helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import pathlib 5 | 6 | TEST_DATA_PATH = pathlib.Path(__file__).parent / ".data" 7 | 8 | 9 | def is_same_tree(tree1, tree2) -> bool: 10 | """Helper function to test if two test trees are the same. 11 | 12 | `is_same_tree` starts by comparing the root attributes, and then checks if all children are the same. 13 | """ 14 | # Compare the root. 15 | if any(tree1[key] != tree2[key] for key in ["path", "name", "type_"]): 16 | return False 17 | 18 | # Compare child test nodes if they exist, otherwise compare test items. 19 | if "children" in tree1 and "children" in tree2: 20 | children1 = tree1["children"] 21 | children2 = tree2["children"] 22 | 23 | # Compare test nodes. 24 | if len(children1) != len(children2): 25 | return False 26 | else: 27 | return all(is_same_tree(*pair) for pair in zip(children1, children2)) 28 | elif "id_" in tree1 and "id_" in tree2: 29 | # Compare test items. 30 | return all(tree1[key] == tree2[key] for key in ["id_", "lineno"]) 31 | 32 | return False 33 | -------------------------------------------------------------------------------- /pythonFiles/tests/util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class Stub(object): 6 | def __init__(self): 7 | self.calls = [] 8 | 9 | def add_call(self, name, args=None, kwargs=None): 10 | self.calls.append((name, args, kwargs)) 11 | 12 | 13 | class StubProxy(object): 14 | def __init__(self, stub=None, name=None): 15 | self.name = name 16 | self.stub = stub if stub is not None else Stub() 17 | 18 | @property 19 | def calls(self): 20 | return self.stub.calls 21 | 22 | def add_call(self, funcname, *args, **kwargs): 23 | callname = funcname 24 | if self.name: 25 | callname = "{}.{}".format(self.name, funcname) 26 | return self.stub.add_call(callname, *args, **kwargs) 27 | -------------------------------------------------------------------------------- /pythonFiles/unittestadapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /requirements.in: -------------------------------------------------------------------------------- 1 | # This file is used to generate requirements.txt. 2 | # To update requirements.txt, run the following commands. 3 | # 1) pip install pip-tools 4 | # 2) pip-compile --generate-hashes requirements.in 5 | 6 | # Unittest test adapter 7 | typing-extensions==4.7.1 8 | 9 | # Fallback env creator for debian 10 | microvenv 11 | 12 | # Checker for installed packages 13 | importlib_metadata 14 | packaging 15 | tomli 16 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile with Python 3.7 3 | # by the following command: 4 | # 5 | # pip-compile --generate-hashes requirements.in 6 | # 7 | importlib-metadata==6.7.0 \ 8 | --hash=sha256:1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4 \ 9 | --hash=sha256:cb52082e659e97afc5dac71e79de97d8681de3aa07ff18578330904a9d18e5b5 10 | # via -r requirements.in 11 | microvenv==2023.2.0 \ 12 | --hash=sha256:5b46296d6a65992946da504bd9e724a5becf5c256091f2f9383e5b4e9f567f23 \ 13 | --hash=sha256:a07e88a8fb5ee90219b86dd90095cb5646462d45d30285ea3b1a3c7cf33616d3 14 | # via -r requirements.in 15 | packaging==23.1 \ 16 | --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ 17 | --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f 18 | # via -r requirements.in 19 | tomli==2.0.1 \ 20 | --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ 21 | --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f 22 | # via -r requirements.in 23 | typing-extensions==4.7.1 \ 24 | --hash=sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36 \ 25 | --hash=sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2 26 | # via 27 | # -r requirements.in 28 | # importlib-metadata 29 | zipp==3.15.0 \ 30 | --hash=sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b \ 31 | --hash=sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556 32 | # via importlib-metadata 33 | -------------------------------------------------------------------------------- /resources/dark/debug.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/discovering-tests.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /resources/dark/export_to_python.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/dark/open-file.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/dark/play.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/dark/repl.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/restart-kernel.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/run-failed-tests.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /resources/dark/run-file.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/run-tests.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/start.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/status-error.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/status-ok.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/dark/stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/dark/trusted.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/resources/demo.gif -------------------------------------------------------------------------------- /resources/light/debug.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/discovering-tests.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /resources/light/export_to_python.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/open-file.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/play.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/repl.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/restart-kernel.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/run-failed-tests.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /resources/light/run-file.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/run-tests.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/start.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/status-error.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/status-ok.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/trusted.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/logo.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /resources/report_issue_template.md: -------------------------------------------------------------------------------- 1 | 2 | # Behaviour 3 | ## Expected vs. Actual 4 | 5 | XXX 6 | 7 | ## Steps to reproduce: 8 | 9 | 1. XXX 10 | 11 | 14 | 15 | 16 | # Diagnostic data 17 | 18 | - Python version (& distribution if applicable, e.g. Anaconda): {0} 19 | - Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1} 20 | - Value of the `python.languageServer` setting: {2} 21 | 22 |
23 | 24 | Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python) 25 | 26 | 27 |

28 | 29 | ``` 30 | XXX 31 | ``` 32 | 33 |

34 |
35 | 36 |
37 | 38 | User Settings 39 | 40 |

41 | 42 | ``` 43 | {3}{4} 44 | ``` 45 | 46 |

47 |
48 | -------------------------------------------------------------------------------- /resources/walkthrough/environments-info.md: -------------------------------------------------------------------------------- 1 | ## Python Environments 2 | 3 | Create Environment Dropdown 4 | 5 | Python virtual environments are considered a best practice in Python development. A virtual environment includes a Python interpreter and any packages you have installed into it, such as numpy or Flask. 6 | 7 | After you create a virtual environment using the **Python: Create Environment** command, you can install packages into the environment. 8 | For example, type `python -m pip install numpy` in an activated terminal to install `numpy` into the environment. 9 | 10 | 🔍 Check out our [docs](https://aka.ms/pythonenvs) to learn more. 11 | -------------------------------------------------------------------------------- /resources/walkthrough/install-python-linux.md: -------------------------------------------------------------------------------- 1 | # Install Python on Linux 2 | 3 | To install the latest version of Python on [Debian-based Linux distributions](https://www.debian.org/), you can create a new terminal (Ctrl + Shift + `) and run the following commands: 4 | 5 | 6 | ``` 7 | sudo apt-get update 8 | sudo apt-get install python3 python3-venv python3-pip 9 | ``` 10 | 11 | For [Fedora-based Linux distributions](https://getfedora.org/), you can run the following: 12 | 13 | ``` 14 | sudo dnf install python3 15 | ``` 16 | 17 | To verify if Python was successfully installed, run the following command in the terminal: 18 | 19 | 20 | ``` 21 | python3 --version 22 | ``` 23 | -------------------------------------------------------------------------------- /resources/walkthrough/install-python-macos.md: -------------------------------------------------------------------------------- 1 | # Install Python on macOS 2 | 3 | If you have [Homebrew](https://brew.sh/) installed, you can install Python by running the following command in the terminal (Ctrl + Shift + `): 4 | 5 | ``` 6 | brew install python3 7 | ``` 8 | 9 | If you don't have Homebrew, you can download a Python installer for macOS from [python.org](https://www.python.org/downloads/mac-osx/). 10 | 11 | To verify if Python was successfully installed, run the following command in the terminal: 12 | 13 | ``` 14 | python3 --version 15 | ``` 16 | -------------------------------------------------------------------------------- /resources/walkthrough/install-python-windows-8.md: -------------------------------------------------------------------------------- 1 | ## Install Python on Windows 2 | 3 | If you don't have Python installed on your Windows machine, you can install it [from python.org](https://www.python.org/downloads). 4 | 5 | To verify it's installed, create a new terminal (Ctrl + Shift + `) and try running the following command: 6 | 7 | ``` 8 | python --version 9 | ``` 10 | 11 | You should see something similar to the following: 12 | ``` 13 | Python 3.9.5 14 | ``` 15 | For additional information about using Python on Windows, see [Using Python on Windows at Python.org](https://docs.python.org/3.10/using/windows.html). 16 | -------------------------------------------------------------------------------- /resources/walkthrough/play-button-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/2673b6bf6f4a80e311cf69a1304fbcb30c41e9c8/resources/walkthrough/play-button-dark.png -------------------------------------------------------------------------------- /scripts/onCreateCommand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install pyenv and Python versions here to avoid using shim. 4 | curl https://pyenv.run | bash 5 | echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc 6 | echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc 7 | # echo 'eval "$(pyenv init -)"' >> ~/.bashrc 8 | 9 | export PYENV_ROOT="$HOME/.pyenv" 10 | command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" 11 | # eval "$(pyenv init -)" Comment this out and DO NOT use shim. 12 | source ~/.bashrc 13 | 14 | # Install Python via pyenv . 15 | pyenv install 3.7:latest 3.8:latest 3.9:latest 3.10:latest 3.11:latest 16 | 17 | # Set default Python version to 3.7 . 18 | pyenv global 3.7.17 19 | 20 | npm ci 21 | 22 | # Create Virutal environment. 23 | pyenv exec python3.7 -m venv .venv 24 | 25 | # Activate Virtual environment. 26 | source /workspaces/vscode-python/.venv/bin/activate 27 | 28 | # Install required Python libraries. 29 | npx gulp installPythonLibs 30 | 31 | /workspaces/vscode-python/.venv/bin/python -m pip install -r build/test-requirements.txt 32 | /workspaces/vscode-python/.venv/bin/python -m pip install -r build/functional-test-requirements.txt 33 | 34 | # Below will crash codespace 35 | # npm run compile 36 | -------------------------------------------------------------------------------- /src/client/.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | server 3 | node_modules -------------------------------------------------------------------------------- /src/client/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | typings/** 3 | out/test/** 4 | test/** 5 | src/** 6 | **/*.map 7 | .gitignore 8 | tsconfig.json 9 | vsc-extension-quickstart.md 10 | -------------------------------------------------------------------------------- /src/client/activation/serviceRegistry.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IServiceManager } from '../ioc/types'; 5 | import { ExtensionActivationManager } from './activationManager'; 6 | import { IExtensionActivationManager } from './types'; 7 | 8 | export function registerTypes(serviceManager: IServiceManager): void { 9 | serviceManager.add(IExtensionActivationManager, ExtensionActivationManager); 10 | } 11 | -------------------------------------------------------------------------------- /src/client/common/application/activeResource.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { inject, injectable } from 'inversify'; 7 | import { Resource } from '../types'; 8 | import { IActiveResourceService, IDocumentManager, IWorkspaceService } from './types'; 9 | 10 | @injectable() 11 | export class ActiveResourceService implements IActiveResourceService { 12 | constructor( 13 | @inject(IDocumentManager) private readonly documentManager: IDocumentManager, 14 | @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, 15 | ) {} 16 | 17 | public getActiveResource(): Resource { 18 | const editor = this.documentManager.activeTextEditor; 19 | if (editor && !editor.document.isUntitled) { 20 | return editor.document.uri; 21 | } 22 | return Array.isArray(this.workspaceService.workspaceFolders) && 23 | this.workspaceService.workspaceFolders.length > 0 24 | ? this.workspaceService.workspaceFolders[0].uri 25 | : undefined; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/client/common/application/terminalManager.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { injectable } from 'inversify'; 5 | import { Event, EventEmitter, Terminal, TerminalOptions, window } from 'vscode'; 6 | import { traceLog } from '../../logging'; 7 | import { ITerminalManager } from './types'; 8 | 9 | @injectable() 10 | export class TerminalManager implements ITerminalManager { 11 | private readonly didOpenTerminal = new EventEmitter(); 12 | constructor() { 13 | window.onDidOpenTerminal((terminal) => { 14 | this.didOpenTerminal.fire(monkeyPatchTerminal(terminal)); 15 | }); 16 | } 17 | public get onDidCloseTerminal(): Event { 18 | return window.onDidCloseTerminal; 19 | } 20 | public get onDidOpenTerminal(): Event { 21 | return this.didOpenTerminal.event; 22 | } 23 | public createTerminal(options: TerminalOptions): Terminal { 24 | return monkeyPatchTerminal(window.createTerminal(options)); 25 | } 26 | } 27 | 28 | /** 29 | * Monkeypatch the terminal to log commands sent. 30 | */ 31 | function monkeyPatchTerminal(terminal: Terminal) { 32 | if (!(terminal as any).isPatched) { 33 | const oldSendText = terminal.sendText.bind(terminal); 34 | terminal.sendText = (text: string, addNewLine: boolean = true) => { 35 | traceLog(`Send text to terminal: ${text}`); 36 | return oldSendText(text, addNewLine); 37 | }; 38 | (terminal as any).isPatched = true; 39 | } 40 | return terminal; 41 | } 42 | -------------------------------------------------------------------------------- /src/client/common/configuration/executionSettings/pipEnvExecution.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { injectable, inject } from 'inversify'; 7 | import { IConfigurationService, IToolExecutionPath } from '../../types'; 8 | 9 | @injectable() 10 | export class PipEnvExecutionPath implements IToolExecutionPath { 11 | constructor(@inject(IConfigurationService) private readonly configService: IConfigurationService) {} 12 | 13 | public get executable(): string { 14 | return this.configService.getSettings().pipenvPath; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/client/common/configuration/service.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { PythonExtension } from '@vscode/python-extension'; 5 | import { inject, injectable } from 'inversify'; 6 | import { Event, Uri, ConfigurationChangeEvent } from 'vscode'; 7 | import { IServiceContainer } from '../../ioc/types'; 8 | import { IWorkspaceService } from '../application/types'; 9 | import { PythonSettings } from '../configSettings'; 10 | import { IConfigurationService, IPythonSettings } from '../types'; 11 | 12 | @injectable() 13 | export class ConfigurationService implements IConfigurationService { 14 | private readonly workspaceService: IWorkspaceService; 15 | 16 | private api!: PythonExtension; 17 | 18 | constructor(@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer) { 19 | this.workspaceService = this.serviceContainer.get(IWorkspaceService); 20 | } 21 | 22 | initialize(api: PythonExtension): void { 23 | this.api = api; 24 | } 25 | 26 | // eslint-disable-next-line class-methods-use-this 27 | public get onDidChange(): Event { 28 | return PythonSettings.onConfigChange(); 29 | } 30 | 31 | public getSettings(resource?: Uri): IPythonSettings { 32 | return PythonSettings.getInstance(this.api, resource, this.workspaceService); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/client/common/contextKey.ts: -------------------------------------------------------------------------------- 1 | import { ICommandManager } from './application/types'; 2 | 3 | export class ContextKey { 4 | public get value(): boolean | undefined { 5 | return this.lastValue; 6 | } 7 | private lastValue?: boolean; 8 | 9 | constructor(private name: string, private commandManager: ICommandManager) {} 10 | 11 | public async set(value: boolean): Promise { 12 | if (this.lastValue === value) { 13 | return; 14 | } 15 | this.lastValue = value; 16 | await this.commandManager.executeCommand('setContext', this.name, this.lastValue); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/client/common/errors/errorUtils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { EOL } from 'os'; 5 | 6 | export class ErrorUtils { 7 | public static outputHasModuleNotInstalledError(moduleName: string, content?: string): boolean { 8 | return content && 9 | (content!.indexOf(`No module named ${moduleName}`) > 0 || 10 | content!.indexOf(`No module named '${moduleName}'`) > 0) 11 | ? true 12 | : false; 13 | } 14 | } 15 | 16 | /** 17 | * Wraps an error with a custom error message, retaining the call stack information. 18 | */ 19 | export class WrappedError extends Error { 20 | constructor(message: string, originalException: Error) { 21 | super(message); 22 | // Retain call stack that trapped the error and rethrows this error. 23 | // Also retain the call stack of the original error. 24 | this.stack = `${new Error('').stack}${EOL}${EOL}${originalException.stack}`; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/client/common/errors/moduleNotInstalledError.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export class ModuleNotInstalledError extends Error { 5 | constructor(moduleName: string) { 6 | super(`Module '${moduleName}' not installed.`); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/client/common/helpers.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { ModuleNotInstalledError } from './errors/moduleNotInstalledError'; 7 | 8 | export function isNotInstalledError(error: Error): boolean { 9 | const isError = typeof error === 'object' && error !== null; 10 | 11 | const errorObj = error; 12 | if (!isError) { 13 | return false; 14 | } 15 | if (error instanceof ModuleNotInstalledError) { 16 | return true; 17 | } 18 | 19 | const isModuleNoInstalledError = error.message.indexOf('No module named') >= 0; 20 | return errorObj.code === 'ENOENT' || errorObj.code === 127 || isModuleNoInstalledError; 21 | } 22 | -------------------------------------------------------------------------------- /src/client/common/platform/fileSystemWatcher.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { RelativePattern, workspace } from 'vscode'; 5 | import { traceError, traceVerbose } from '../../logging'; 6 | import { Disposables } from '../utils/resourceLifecycle'; 7 | import { IDisposable } from '../types'; 8 | 9 | /** 10 | * Enumeration of file change types. 11 | */ 12 | export enum FileChangeType { 13 | Changed = 'changed', 14 | Created = 'created', 15 | Deleted = 'deleted', 16 | } 17 | 18 | export function watchLocationForPattern( 19 | baseDir: string, 20 | pattern: string, 21 | callback: (type: FileChangeType, absPath: string) => void, 22 | ): IDisposable { 23 | const globPattern = new RelativePattern(baseDir, pattern); 24 | const disposables = new Disposables(); 25 | traceVerbose(`Start watching: ${baseDir} with pattern ${pattern} using VSCode API`); 26 | try { 27 | const watcher = workspace.createFileSystemWatcher(globPattern); 28 | disposables.push(watcher.onDidCreate((e) => callback(FileChangeType.Created, e.fsPath))); 29 | disposables.push(watcher.onDidChange((e) => callback(FileChangeType.Changed, e.fsPath))); 30 | disposables.push(watcher.onDidDelete((e) => callback(FileChangeType.Deleted, e.fsPath))); 31 | } catch (ex) { 32 | traceError(`Failed to create File System watcher for patter ${pattern} in ${baseDir}`, ex); 33 | } 34 | return disposables; 35 | } 36 | -------------------------------------------------------------------------------- /src/client/common/platform/registry.ts: -------------------------------------------------------------------------------- 1 | import { Architecture } from '../utils/platform'; 2 | 3 | export function getArchitectureDisplayName(arch?: Architecture) { 4 | switch (arch) { 5 | case Architecture.x64: 6 | return '64-bit'; 7 | case Architecture.x86: 8 | return '32-bit'; 9 | default: 10 | return ''; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/client/common/platform/serviceRegistry.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 'use strict'; 4 | 5 | import { IServiceManager } from '../../ioc/types'; 6 | import { FileSystem } from './fileSystem'; 7 | import { PlatformService } from './platformService'; 8 | import { IFileSystem, IPlatformService } from './types'; 9 | 10 | export function registerTypes(serviceManager: IServiceManager) { 11 | serviceManager.addSingleton(IPlatformService, PlatformService); 12 | serviceManager.addSingleton(IFileSystem, FileSystem); 13 | } 14 | -------------------------------------------------------------------------------- /src/client/common/process/constants.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export const DEFAULT_ENCODING = 'utf8'; 5 | -------------------------------------------------------------------------------- /src/client/common/process/currentProcess.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 'use strict'; 4 | 5 | import { injectable } from 'inversify'; 6 | import { ICurrentProcess } from '../types'; 7 | import { EnvironmentVariables } from '../variables/types'; 8 | 9 | @injectable() 10 | export class CurrentProcess implements ICurrentProcess { 11 | public on = (event: string | symbol, listener: Function): this => { 12 | process.on(event as any, listener as any); 13 | return process as any; 14 | }; 15 | public get env(): EnvironmentVariables { 16 | return (process.env as any) as EnvironmentVariables; 17 | } 18 | public get argv(): string[] { 19 | return process.argv; 20 | } 21 | public get stdout(): NodeJS.WriteStream { 22 | return process.stdout; 23 | } 24 | public get stdin(): NodeJS.ReadStream { 25 | return process.stdin; 26 | } 27 | 28 | public get execPath(): string { 29 | return process.execPath; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/client/common/process/decoder.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import * as iconv from 'iconv-lite'; 5 | import { DEFAULT_ENCODING } from './constants'; 6 | 7 | export function decodeBuffer(buffers: Buffer[], encoding: string = DEFAULT_ENCODING): string { 8 | encoding = iconv.encodingExists(encoding) ? encoding : DEFAULT_ENCODING; 9 | return iconv.decode(Buffer.concat(buffers), encoding); 10 | } 11 | -------------------------------------------------------------------------------- /src/client/common/process/internal/scripts/constants.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import * as path from 'path'; 5 | import { EXTENSION_ROOT_DIR } from '../../../constants'; 6 | 7 | // It is simpler to hard-code it instead of using vscode.ExtensionContext.extensionPath. 8 | export const _SCRIPTS_DIR = path.join(EXTENSION_ROOT_DIR, 'pythonFiles'); 9 | -------------------------------------------------------------------------------- /src/client/common/process/processFactory.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { inject, injectable } from 'inversify'; 7 | import { Uri } from 'vscode'; 8 | import { IDisposableRegistry } from '../types'; 9 | import { IEnvironmentVariablesProvider } from '../variables/types'; 10 | import { ProcessService } from './proc'; 11 | import { IProcessLogger, IProcessService, IProcessServiceFactory } from './types'; 12 | 13 | @injectable() 14 | export class ProcessServiceFactory implements IProcessServiceFactory { 15 | constructor( 16 | @inject(IEnvironmentVariablesProvider) private readonly envVarsService: IEnvironmentVariablesProvider, 17 | @inject(IProcessLogger) private readonly processLogger: IProcessLogger, 18 | @inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry, 19 | ) {} 20 | public async create(resource?: Uri, options?: { doNotUseCustomEnvs: boolean }): Promise { 21 | const customEnvVars = options?.doNotUseCustomEnvs 22 | ? undefined 23 | : await this.envVarsService.getEnvironmentVariables(resource); 24 | const proc: IProcessService = new ProcessService(customEnvVars); 25 | this.disposableRegistry.push(proc); 26 | return proc.on('exec', this.processLogger.logProcess.bind(this.processLogger)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/client/common/process/serviceRegistry.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IServiceManager } from '../../ioc/types'; 5 | import { ProcessServiceFactory } from './processFactory'; 6 | import { PythonExecutionFactory } from './pythonExecutionFactory'; 7 | import { PythonToolExecutionService } from './pythonToolService'; 8 | import { IProcessServiceFactory, IPythonExecutionFactory, IPythonToolExecutionService } from './types'; 9 | 10 | export function registerTypes(serviceManager: IServiceManager) { 11 | serviceManager.addSingleton(IProcessServiceFactory, ProcessServiceFactory); 12 | serviceManager.addSingleton(IPythonExecutionFactory, PythonExecutionFactory); 13 | serviceManager.addSingleton(IPythonToolExecutionService, PythonToolExecutionService); 14 | } 15 | -------------------------------------------------------------------------------- /src/client/common/stringUtils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export interface SplitLinesOptions { 5 | trim?: boolean; 6 | removeEmptyEntries?: boolean; 7 | } 8 | 9 | /** 10 | * Split a string using the cr and lf characters and return them as an array. 11 | * By default lines are trimmed and empty lines are removed. 12 | * @param {SplitLinesOptions=} splitOptions - Options used for splitting the string. 13 | */ 14 | export function splitLines( 15 | source: string, 16 | splitOptions: SplitLinesOptions = { removeEmptyEntries: true, trim: true }, 17 | ): string[] { 18 | let lines = source.split(/\r?\n/g); 19 | if (splitOptions?.trim) { 20 | lines = lines.map((line) => line.trim()); 21 | } 22 | if (splitOptions?.removeEmptyEntries) { 23 | lines = lines.filter((line) => line.length > 0); 24 | } 25 | return lines; 26 | } 27 | 28 | /** 29 | * Replaces all instances of a substring with a new substring. 30 | */ 31 | export function replaceAll(source: string, substr: string, newSubstr: string): string { 32 | if (!source) { 33 | return source; 34 | } 35 | 36 | /** Escaping function from the MDN web docs site 37 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping 38 | * Escapes all the following special characters in a string . * + ? ^ $ { } ( ) | \ \\ 39 | */ 40 | 41 | function escapeRegExp(unescapedStr: string): string { 42 | return unescapedStr.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string 43 | } 44 | 45 | return source.replace(new RegExp(escapeRegExp(substr), 'g'), newSubstr); 46 | } 47 | -------------------------------------------------------------------------------- /src/client/common/terminal/activator/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { inject, injectable } from 'inversify'; 7 | import { Terminal } from 'vscode'; 8 | import { ITerminalActivator, ITerminalHelper, TerminalActivationOptions } from '../types'; 9 | import { BaseTerminalActivator } from './base'; 10 | 11 | @injectable() 12 | export class TerminalActivator implements ITerminalActivator { 13 | protected baseActivator!: ITerminalActivator; 14 | private pendingActivations = new WeakMap>(); 15 | constructor( 16 | @inject(ITerminalHelper) readonly helper: ITerminalHelper, 17 | ) { 18 | this.initialize(); 19 | } 20 | public async activateEnvironmentInTerminal( 21 | terminal: Terminal, 22 | options?: TerminalActivationOptions, 23 | ): Promise { 24 | let promise = this.pendingActivations.get(terminal); 25 | if (promise) { 26 | return promise; 27 | } 28 | promise = this.activateEnvironmentInTerminalImpl(terminal, options); 29 | this.pendingActivations.set(terminal, promise); 30 | return promise; 31 | } 32 | private async activateEnvironmentInTerminalImpl( 33 | _terminal: Terminal, 34 | _options?: TerminalActivationOptions, 35 | ): Promise { 36 | return false; 37 | } 38 | protected initialize() { 39 | this.baseActivator = new BaseTerminalActivator(this.helper); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/client/common/terminal/environmentActivationProviders/nushell.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { injectable } from 'inversify'; 5 | import '../../extensions'; 6 | import { TerminalShellType } from '../types'; 7 | import { ActivationScripts, VenvBaseActivationCommandProvider } from './baseActivationProvider'; 8 | 9 | // For a given shell the scripts are in order of precedence. 10 | const SCRIPTS: ActivationScripts = { 11 | [TerminalShellType.nushell]: ['activate.nu'], 12 | }; 13 | 14 | export function getAllScripts(): string[] { 15 | const scripts: string[] = []; 16 | for (const names of Object.values(SCRIPTS)) { 17 | for (const name of names) { 18 | if (!scripts.includes(name)) { 19 | scripts.push(name); 20 | } 21 | } 22 | } 23 | return scripts; 24 | } 25 | 26 | @injectable() 27 | export class Nushell extends VenvBaseActivationCommandProvider { 28 | protected readonly scripts = SCRIPTS; 29 | 30 | public async getActivationCommandsForInterpreter( 31 | pythonPath: string, 32 | targetShell: TerminalShellType, 33 | ): Promise { 34 | const scriptFile = await this.findScriptFile(pythonPath, targetShell); 35 | if (!scriptFile) { 36 | return undefined; 37 | } 38 | return [`overlay use ${scriptFile.fileToCommandArgumentForPythonMgrExt()}`]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/client/common/terminal/shellDetectors/terminalNameShellDetector.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { injectable } from 'inversify'; 7 | import { Terminal } from 'vscode'; 8 | import { traceVerbose } from '../../../logging'; 9 | import { ShellIdentificationTelemetry, TerminalShellType } from '../types'; 10 | import { BaseShellDetector } from './baseShellDetector'; 11 | 12 | /** 13 | * Identifies the shell, based on the display name of the terminal. 14 | * 15 | * @export 16 | * @class TerminalNameShellDetector 17 | * @extends {BaseShellDetector} 18 | */ 19 | @injectable() 20 | export class TerminalNameShellDetector extends BaseShellDetector { 21 | constructor() { 22 | super(4); 23 | } 24 | public identify( 25 | telemetryProperties: ShellIdentificationTelemetry, 26 | terminal?: Terminal, 27 | ): TerminalShellType | undefined { 28 | if (!terminal) { 29 | return; 30 | } 31 | const shell = this.identifyShellFromShellPath(terminal.name); 32 | traceVerbose(`Terminal name '${terminal.name}' identified as shell '${shell}'`); 33 | telemetryProperties.shellIdentificationSource = 34 | shell === TerminalShellType.other ? telemetryProperties.shellIdentificationSource : 'terminalName'; 35 | return shell; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/client/common/utils/arrayUtils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /** 5 | * Returns the elements of an array that meet the condition specified in an async callback function. 6 | * @param asyncPredicate The filter method calls the async predicate function one time for each element in the array. 7 | */ 8 | export async function asyncFilter(arr: T[], asyncPredicate: (value: T) => Promise): Promise { 9 | const results = await Promise.all(arr.map(asyncPredicate)); 10 | return arr.filter((_v, index) => results[index]); 11 | } 12 | 13 | export async function asyncForEach(arr: T[], asyncFunc: (value: T) => Promise): Promise { 14 | await Promise.all(arr.map(asyncFunc)); 15 | } 16 | -------------------------------------------------------------------------------- /src/client/common/utils/enum.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | export function getNamesAndValues(e: any): { name: string; value: T }[] { 7 | return getNames(e).map((n) => ({ name: n, value: e[n] })); 8 | } 9 | 10 | function getNames(e: any) { 11 | return getObjValues(e).filter((v) => typeof v === 'string') as string[]; 12 | } 13 | 14 | export function getValues(e: any) { 15 | return (getObjValues(e).filter((v) => typeof v === 'number') as any) as T[]; 16 | } 17 | 18 | function getObjValues(e: any): (number | string)[] { 19 | return Object.keys(e).map((k) => e[k]); 20 | } 21 | -------------------------------------------------------------------------------- /src/client/common/utils/icons.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import * as path from 'path'; 7 | import { Uri } from 'vscode'; 8 | import { EXTENSION_ROOT_DIR } from '../../constants'; 9 | 10 | const darkIconsPath = path.join(EXTENSION_ROOT_DIR, 'resources', 'dark'); 11 | const lightIconsPath = path.join(EXTENSION_ROOT_DIR, 'resources', 'light'); 12 | 13 | export function getIcon(fileName: string): { light: Uri; dark: Uri } { 14 | return { 15 | dark: Uri.file(path.join(darkIconsPath, fileName)), 16 | light: Uri.file(path.join(lightIconsPath, fileName)), 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/client/common/utils/random.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import * as crypto from 'crypto'; 7 | import { injectable } from 'inversify'; 8 | import { IRandom } from '../types'; 9 | 10 | function getRandom(): number { 11 | let num: number = 0; 12 | 13 | const buf: Buffer = crypto.randomBytes(2); 14 | num = (buf.readUInt8(0) << 8) + buf.readUInt8(1); 15 | 16 | const maxValue: number = Math.pow(16, 4) - 1; 17 | return num / maxValue; 18 | } 19 | 20 | function getRandomBetween(min: number = 0, max: number = 10): number { 21 | const randomVal: number = getRandom(); 22 | return min + randomVal * (max - min); 23 | } 24 | 25 | @injectable() 26 | export class Random implements IRandom { 27 | public getRandomInt(min: number = 0, max: number = 10): number { 28 | return getRandomBetween(min, max); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/client/common/utils/regexp.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | /* Generate a RegExp from a "verbose" pattern. 7 | * 8 | * All whitespace in the pattern is removed, including newlines. This 9 | * allows the pattern to be much more readable by allowing it to span 10 | * multiple lines and to separate tokens with insignificant whitespace. 11 | * The functionality is similar to the VERBOSE ("x") flag in Python's 12 | * regular expressions. 13 | * 14 | * Note that significant whitespace in the pattern must be explicitly 15 | * indicated by "\s". Also, unlike with regular expression literals, 16 | * backslashes must be escaped. Conversely, forward slashes do not 17 | * need to be escaped. 18 | * 19 | * Line comments are also removed. A comment is two spaces followed 20 | * by `#` followed by a space and then the rest of the text to the 21 | * end of the line. 22 | */ 23 | export function verboseRegExp(pattern: string, flags?: string): RegExp { 24 | pattern = pattern.replace(/(^| {2})# .*$/gm, ''); 25 | pattern = pattern.replace(/\s+?/g, ''); 26 | return RegExp(pattern, flags); 27 | } 28 | -------------------------------------------------------------------------------- /src/client/common/utils/resourceLifecycle.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IDisposable } from '../types'; 5 | 6 | interface IDisposables extends IDisposable { 7 | push(...disposable: IDisposable[]): void; 8 | } 9 | 10 | /** 11 | * Safely dispose each of the disposables. 12 | */ 13 | export async function disposeAll(disposables: IDisposable[]): Promise { 14 | await Promise.all( 15 | disposables.map(async (d) => { 16 | try { 17 | return Promise.resolve(d.dispose()); 18 | } catch (err) { 19 | // do nothing 20 | } 21 | return Promise.resolve(); 22 | }), 23 | ); 24 | } 25 | 26 | /** 27 | * A list of disposables. 28 | */ 29 | export class Disposables implements IDisposables { 30 | private disposables: IDisposable[] = []; 31 | 32 | constructor(...disposables: IDisposable[]) { 33 | this.disposables.push(...disposables); 34 | } 35 | 36 | public push(...disposables: IDisposable[]): void { 37 | this.disposables.push(...disposables); 38 | } 39 | 40 | public async dispose(): Promise { 41 | const { disposables } = this; 42 | this.disposables = []; 43 | await disposeAll(disposables); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/client/common/utils/stopWatch.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | export class StopWatch implements IStopWatch { 7 | private started = new Date().getTime(); 8 | public get elapsedTime() { 9 | return new Date().getTime() - this.started; 10 | } 11 | public reset() { 12 | this.started = new Date().getTime(); 13 | } 14 | } 15 | 16 | export interface IStopWatch { 17 | elapsedTime: number; 18 | } 19 | -------------------------------------------------------------------------------- /src/client/common/variables/serviceRegistry.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IServiceManager } from '../../ioc/types'; 5 | import { EnvironmentVariablesService } from './environment'; 6 | import { EnvironmentVariablesProvider } from './environmentVariablesProvider'; 7 | import { IEnvironmentVariablesProvider, IEnvironmentVariablesService } from './types'; 8 | 9 | export function registerTypes(serviceManager: IServiceManager) { 10 | serviceManager.addSingleton( 11 | IEnvironmentVariablesService, 12 | EnvironmentVariablesService, 13 | ); 14 | serviceManager.addSingleton( 15 | IEnvironmentVariablesProvider, 16 | EnvironmentVariablesProvider, 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /src/client/common/vscodeApis/commandApis.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { commands, Disposable } from 'vscode'; 5 | 6 | /* eslint-disable @typescript-eslint/no-explicit-any */ 7 | /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ 8 | 9 | export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable { 10 | return commands.registerCommand(command, callback, thisArg); 11 | } 12 | 13 | export function executeCommand(command: string, ...rest: any[]): Thenable { 14 | return commands.executeCommand(command, ...rest); 15 | } 16 | -------------------------------------------------------------------------------- /src/client/components.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IDisposableRegistry, IExtensionContext } from './common/types'; 5 | import { IServiceContainer, IServiceManager } from './ioc/types'; 6 | 7 | /** 8 | * The global extension state needed by components. 9 | * 10 | */ 11 | export type ExtensionState = { 12 | context: IExtensionContext; 13 | disposables: IDisposableRegistry; 14 | // For now we include the objects dealing with inversify (IOC) 15 | // registration. These will be removed later. 16 | legacyIOC: { 17 | serviceManager: IServiceManager; 18 | serviceContainer: IServiceContainer; 19 | }; 20 | }; 21 | 22 | /** 23 | * The result of activating a component of the extension. 24 | * 25 | * Getting this value means the component has reached a state where it 26 | * may be used by the rest of the extension. 27 | * 28 | * If the component started any non-critical activation-related 29 | * operations during activation then the "fullyReady" property will only 30 | * resolve once all those operations complete. 31 | * 32 | * The component may have also started long-running background helpers. 33 | * Those are not exposed here. 34 | */ 35 | export type ActivationResult = { 36 | fullyReady: Promise; 37 | }; 38 | -------------------------------------------------------------------------------- /src/client/constants.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import * as path from 'path'; 7 | 8 | // This file is also used by the debug adapter. 9 | // When bundling, the bundle file for the debug adapter ends up elsewhere. 10 | const folderName = path.basename(__dirname); 11 | export const EXTENSION_ROOT_DIR = 12 | folderName === 'client' ? path.join(__dirname, '..', '..') : path.join(__dirname, '..', '..', '..', '..'); 13 | 14 | export const HiddenFilePrefix = '_HiddenFile_'; 15 | -------------------------------------------------------------------------------- /src/client/interpreter/activation/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { Resource } from '../../common/types'; 7 | import { EnvironmentVariables } from '../../common/variables/types'; 8 | import { PythonEnvironment } from '../../pythonEnvironments/info'; 9 | 10 | export const IEnvironmentActivationService = Symbol('IEnvironmentActivationService'); 11 | export interface IEnvironmentActivationService { 12 | getProcessEnvironmentVariables(resource: Resource, shell?: string): Promise; 13 | getActivatedEnvironmentVariables( 14 | resource: Resource, 15 | interpreter?: PythonEnvironment, 16 | allowExceptions?: boolean, 17 | shell?: string, 18 | ): Promise; 19 | getEnvironmentActivationShellCommands( 20 | resource: Resource, 21 | interpreter?: PythonEnvironment, 22 | ): Promise; 23 | } 24 | 25 | export const ITerminalEnvVarCollectionService = Symbol('ITerminalEnvVarCollectionService'); 26 | export interface ITerminalEnvVarCollectionService { 27 | /** 28 | * Returns true if we know with high certainity the terminal prompt is set correctly for a particular resource. 29 | */ 30 | isTerminalPromptSetCorrectly(resource?: Resource): boolean; 31 | } 32 | -------------------------------------------------------------------------------- /src/client/interpreter/locators/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { Uri } from 'vscode'; 7 | 8 | export const IPythonInPathCommandProvider = Symbol('IPythonInPathCommandProvider'); 9 | export interface IPythonInPathCommandProvider { 10 | getCommands(): { command: string; args?: string[] }[]; 11 | } 12 | export const IPipEnvServiceHelper = Symbol('IPipEnvServiceHelper'); 13 | export interface IPipEnvServiceHelper { 14 | getPipEnvInfo(pythonPath: string): Promise<{ workspaceFolder: Uri; envName: string } | undefined>; 15 | trackWorkspaceFolder(pythonPath: string, workspaceFolder: Uri): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /src/client/logging/outputChannelLogger.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import * as util from 'util'; 5 | import { OutputChannel } from 'vscode'; 6 | import { Arguments, ILogging } from './types'; 7 | 8 | export class OutputChannelLogger implements ILogging { 9 | constructor(private readonly channel: OutputChannel) { } 10 | 11 | public traceLog(...data: Arguments): void { 12 | this.channel.appendLine(util.format(...data)); 13 | } 14 | 15 | public traceError(...data: Arguments): void { 16 | this.channel.appendLine(`Error: ${util.format(...data)}`); 17 | } 18 | 19 | public traceWarn(...data: Arguments): void { 20 | this.channel.appendLine(`Warn: ${util.format(...data)}`); 21 | } 22 | 23 | public traceInfo(...data: Arguments): void { 24 | this.channel.appendLine(`Info: ${util.format(...data)}`); 25 | } 26 | 27 | public traceVerbose(...data: Arguments): void { 28 | this.channel.appendLine(`Debug: ${util.format(...data)}`); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/client/logging/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* eslint-disable @typescript-eslint/ban-types */ 5 | /* eslint-disable @typescript-eslint/no-explicit-any */ 6 | 7 | export type Arguments = unknown[]; 8 | 9 | export enum LogLevel { 10 | Off = 0, 11 | Trace = 1, 12 | Debug = 2, 13 | Info = 3, 14 | Warning = 4, 15 | Error = 5, 16 | } 17 | 18 | export interface ILogging { 19 | traceLog(...data: Arguments): void; 20 | traceError(...data: Arguments): void; 21 | traceWarn(...data: Arguments): void; 22 | traceInfo(...data: Arguments): void; 23 | traceVerbose(...data: Arguments): void; 24 | } 25 | 26 | export type TraceDecoratorType = ( 27 | _: Object, 28 | __: string, 29 | descriptor: TypedPropertyDescriptor, 30 | ) => TypedPropertyDescriptor; 31 | 32 | // The information we want to log. 33 | export enum TraceOptions { 34 | None = 0, 35 | Arguments = 1, 36 | ReturnValue = 2, 37 | } 38 | -------------------------------------------------------------------------------- /src/client/logging/util.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | import { Uri } from 'vscode'; 7 | 8 | export type Arguments = unknown[]; 9 | 10 | function valueToLogString(value: unknown, kind: string): string { 11 | if (value === undefined) { 12 | return 'undefined'; 13 | } 14 | if (value === null) { 15 | return 'null'; 16 | } 17 | try { 18 | if (value && (value as Uri).fsPath) { 19 | return ``; 20 | } 21 | return JSON.stringify(value); 22 | } catch { 23 | return `<${kind} cannot be serialized for logging>`; 24 | } 25 | } 26 | 27 | // Convert the given array of values (func call arguments) into a string 28 | // suitable to be used in a log message. 29 | export function argsToLogString(args: Arguments): string { 30 | if (!args) { 31 | return ''; 32 | } 33 | try { 34 | const argStrings = args.map((item, index) => { 35 | const valueString = valueToLogString(item, 'argument'); 36 | return `Arg ${index + 1}: ${valueString}`; 37 | }); 38 | return argStrings.join(', '); 39 | } catch { 40 | return ''; 41 | } 42 | } 43 | 44 | // Convert the given return value into a string 45 | // suitable to be used in a log message. 46 | export function returnValueToLogString(returnValue: unknown): string { 47 | const valueString = valueToLogString(returnValue, 'Return value'); 48 | return `Return Value: ${valueString}`; 49 | } 50 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/base/info/executable.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import * as path from 'path'; 5 | import { getOSType, OSType } from '../../../common/utils/platform'; 6 | import { getEmptyVersion, parseVersion } from './pythonVersion'; 7 | 8 | import { PythonVersion } from '.'; 9 | import { normCasePath } from '../../common/externalDependencies'; 10 | 11 | /** 12 | * Determine a best-effort Python version based on the given filename. 13 | */ 14 | export function parseVersionFromExecutable(filename: string): PythonVersion { 15 | const version = parseBasename(path.basename(filename)); 16 | 17 | if (version.major === 2 && version.minor === -1) { 18 | version.minor = 7; 19 | } 20 | 21 | return version; 22 | } 23 | 24 | function parseBasename(basename: string): PythonVersion { 25 | basename = normCasePath(basename); 26 | if (getOSType() === OSType.Windows) { 27 | if (basename === 'python.exe') { 28 | // On Windows we can't assume it is 2.7. 29 | return getEmptyVersion(); 30 | } 31 | } else if (basename === 'python') { 32 | // We can assume it is 2.7. (See PEP 394.) 33 | return parseVersion('2.7'); 34 | } 35 | if (!basename.startsWith('python')) { 36 | throw Error(`not a Python executable (expected "python..", got "${basename}")`); 37 | } 38 | // If we reach here then we expect it to have a version in the name. 39 | return parseVersion(basename); 40 | } 41 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/base/watchers.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { Event } from 'vscode'; 5 | import { IDisposable } from '../../common/types'; 6 | import { Disposables } from '../../common/utils/resourceLifecycle'; 7 | import { IPythonEnvsWatcher, PythonEnvsChangedEvent, PythonEnvsWatcher } from './watcher'; 8 | 9 | /** 10 | * A wrapper around a set of watchers, exposing them as a single watcher. 11 | * 12 | * If any of the wrapped watchers emits an event then this wrapper 13 | * emits that event. 14 | */ 15 | export class PythonEnvsWatchers implements IPythonEnvsWatcher, IDisposable { 16 | public readonly onChanged: Event; 17 | 18 | private readonly watcher = new PythonEnvsWatcher(); 19 | 20 | private readonly disposables = new Disposables(); 21 | 22 | constructor(watchers: ReadonlyArray) { 23 | this.onChanged = this.watcher.onChanged; 24 | watchers.forEach((w) => { 25 | const disposable = w.onChanged((e) => this.watcher.fire(e)); 26 | this.disposables.push(disposable); 27 | }); 28 | } 29 | 30 | public async dispose(): Promise { 31 | await this.disposables.dispose(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/common/environmentManagers/macDefault.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { getOSType, OSType } from '../../../common/utils/platform'; 5 | 6 | /** 7 | * Decide if the given Python executable looks like the MacOS default Python. 8 | */ 9 | export function isMacDefaultPythonPath(pythonPath: string): boolean { 10 | if (getOSType() !== OSType.OSX) { 11 | return false; 12 | } 13 | 14 | const defaultPaths = ['/usr/bin/python']; 15 | 16 | return defaultPaths.includes(pythonPath) || pythonPath.startsWith('/usr/bin/python2'); 17 | } 18 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/common/windowsRegistry.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { HKCU, HKLM, Options, REG_SZ, Registry, RegistryItem } from 'winreg'; 5 | import { createDeferred } from '../../common/utils/async'; 6 | 7 | export { HKCU, HKLM, REG_SZ, Options }; 8 | 9 | export interface IRegistryKey { 10 | hive: string; 11 | arch: string; 12 | key: string; 13 | parentKey?: IRegistryKey; 14 | } 15 | 16 | export interface IRegistryValue { 17 | hive: string; 18 | arch: string; 19 | key: string; 20 | name: string; 21 | type: string; 22 | value: string; 23 | } 24 | 25 | export async function readRegistryValues(options: Options): Promise { 26 | // eslint-disable-next-line global-require 27 | const WinReg = require('winreg'); 28 | const regKey = new WinReg(options); 29 | const deferred = createDeferred(); 30 | regKey.values((err: Error, res: RegistryItem[]) => { 31 | if (err) { 32 | deferred.reject(err); 33 | } 34 | deferred.resolve(res); 35 | }); 36 | return deferred.promise; 37 | } 38 | 39 | export async function readRegistryKeys(options: Options): Promise { 40 | // eslint-disable-next-line global-require 41 | const WinReg = require('winreg'); 42 | const regKey = new WinReg(options); 43 | const deferred = createDeferred(); 44 | regKey.keys((err: Error, res: Registry[]) => { 45 | if (err) { 46 | deferred.reject(err); 47 | } 48 | deferred.resolve(res); 49 | }); 50 | return deferred.promise; 51 | } 52 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/creation/common/commonUtils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | import * as fs from 'fs-extra'; 4 | import * as path from 'path'; 5 | import { WorkspaceFolder } from 'vscode'; 6 | import { Commands } from '../../../common/constants'; 7 | import { Common } from '../../../common/utils/localize'; 8 | import { executeCommand } from '../../../common/vscodeApis/commandApis'; 9 | import { showErrorMessage } from '../../../common/vscodeApis/windowApis'; 10 | import { isWindows } from '../../../common/platform/platformService'; 11 | 12 | export async function showErrorMessageWithLogs(message: string): Promise { 13 | const result = await showErrorMessage(message, Common.openOutputPanel, Common.selectPythonInterpreter); 14 | if (result === Common.openOutputPanel) { 15 | await executeCommand(Commands.ViewOutput); 16 | } else if (result === Common.selectPythonInterpreter) { 17 | await executeCommand(Commands.Set_Interpreter); 18 | } 19 | } 20 | 21 | export function getVenvPath(workspaceFolder: WorkspaceFolder): string { 22 | return path.join(workspaceFolder.uri.fsPath, '.venv'); 23 | } 24 | 25 | export async function hasVenv(workspaceFolder: WorkspaceFolder): Promise { 26 | return fs.pathExists(getVenvPath(workspaceFolder)); 27 | } 28 | 29 | export function getVenvExecutable(workspaceFolder: WorkspaceFolder): string { 30 | if (isWindows()) { 31 | return path.join(getVenvPath(workspaceFolder), 'Scripts', 'python.exe'); 32 | } 33 | return path.join(getVenvPath(workspaceFolder), 'bin', 'python'); 34 | } 35 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/creation/createEnvButtonContext.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IDisposableRegistry } from '../../common/types'; 5 | import { executeCommand } from '../../common/vscodeApis/commandApis'; 6 | import { getConfiguration, onDidChangeConfiguration } from '../../common/vscodeApis/workspaceApis'; 7 | 8 | async function setShowCreateEnvButtonContextKey(): Promise { 9 | const config = getConfiguration('python'); 10 | const showCreateEnvButton = config.get('createEnvironment.contentButton', 'show') === 'show'; 11 | await executeCommand('setContext', 'showCreateEnvButton', showCreateEnvButton); 12 | } 13 | 14 | export function registerCreateEnvironmentButtonFeatures(disposables: IDisposableRegistry): void { 15 | disposables.push( 16 | onDidChangeConfiguration(async () => { 17 | await setShowCreateEnvButtonContextKey(); 18 | }), 19 | ); 20 | 21 | setShowCreateEnvButtonContextKey(); 22 | } 23 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/creation/provider/venvSwitchPython.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import * as path from 'path'; 5 | import { Disposable, Uri, extensions } from 'vscode'; 6 | import { PVSC_EXTENSION_ID, PythonExtension } from '@vscode/python-extension'; 7 | import { createDeferred } from '../../../common/utils/async'; 8 | import { traceInfo } from '../../../logging'; 9 | 10 | export async function switchSelectedPython(interpreter: string, uri: Uri, purpose: string): Promise { 11 | let dispose: Disposable | undefined; 12 | try { 13 | const deferred = createDeferred(); 14 | const api = extensions.getExtension(PVSC_EXTENSION_ID)?.exports; 15 | if (!api) { 16 | throw new Error('Api not exported by Python extension') 17 | } 18 | dispose = api.environments.onDidChangeActiveEnvironmentPath(async (e) => { 19 | if (path.normalize(e.path) === path.normalize(interpreter)) { 20 | traceInfo(`Switched to interpreter ${purpose}: ${interpreter}`); 21 | deferred.resolve(); 22 | } 23 | }); 24 | api.environments.updateActiveEnvironmentPath(interpreter, uri); 25 | traceInfo(`Switching interpreter ${purpose}: ${interpreter}`); 26 | await deferred.promise; 27 | } finally { 28 | dispose?.dispose(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/creation/registrations.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { IDisposableRegistry } from '../../common/types'; 5 | import { IInterpreterQuickPick } from '../../interpreter/configuration/types'; 6 | import { registerCreateEnvironmentFeatures } from './createEnvApi'; 7 | import { registerCreateEnvironmentButtonFeatures } from './createEnvButtonContext'; 8 | 9 | export function registerAllCreateEnvironmentFeatures( 10 | disposables: IDisposableRegistry, 11 | interpreterQuickPick: IInterpreterQuickPick, 12 | ): void { 13 | registerCreateEnvironmentFeatures(disposables, interpreterQuickPick); 14 | registerCreateEnvironmentButtonFeatures(disposables); 15 | } 16 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/creation/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License 3 | 4 | import { Progress } from 'vscode'; 5 | 6 | export interface CreateEnvironmentProgress extends Progress<{ message?: string; increment?: number }> {} 7 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/info/executable.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { getExecutable } from '../../common/process/internal/python'; 5 | import { ShellExecFunc } from '../../common/process/types'; 6 | import { traceError } from '../../logging'; 7 | import { copyPythonExecInfo, PythonExecInfo } from '../exec'; 8 | 9 | /** 10 | * Find the filename for the corresponding Python executable. 11 | * 12 | * Effectively, we look up `sys.executable`. 13 | * 14 | * @param python - the information to use when running Python 15 | * @param shellExec - the function to use to run Python 16 | */ 17 | export async function getExecutablePath(python: PythonExecInfo, shellExec: ShellExecFunc): Promise { 18 | try { 19 | const [args, parse] = getExecutable(); 20 | const info = copyPythonExecInfo(python, args); 21 | const argv = [info.command, ...info.args]; 22 | // Concat these together to make a set of quoted strings 23 | const quoted = argv.reduce( 24 | (p, c) => (p ? `${p} ${c.toCommandArgumentForPythonMgrExt()}` : `${c.toCommandArgumentForPythonMgrExt()}`), 25 | '', 26 | ); 27 | const result = await shellExec(quoted, { timeout: 15000 }); 28 | const executable = parse(result.stdout.trim()); 29 | if (executable === '') { 30 | throw new Error(`${quoted} resulted in empty stdout`); 31 | } 32 | return executable; 33 | } catch (ex) { 34 | traceError(ex); 35 | return undefined; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/client/pythonEnvironments/info/pythonVersion.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /** 5 | * A representation of a Python runtime's version. 6 | * 7 | * @prop raw - the original version string 8 | * @prop major - the "major" version 9 | * @prop minor - the "minor" version 10 | * @prop patch - the "patch" (or "micro") version 11 | * @prop build - the build ID of the executable 12 | * @prop prerelease - identifies a tag in the release process (e.g. beta 1) 13 | */ 14 | // Note that this is currently compatible with SemVer objects, 15 | // but we may change it to match the format of sys.version_info. 16 | export type PythonVersion = { 17 | raw: string; 18 | major: number; 19 | minor: number; 20 | patch: number; 21 | // Eventually it may be useful to match what sys.version_info 22 | // provides for the remainder here: 23 | // * releaseLevel: 'alpha' | 'beta' | 'candidate' | 'final'; 24 | // * serial: number; 25 | build: string[]; 26 | prerelease: string[]; 27 | }; 28 | -------------------------------------------------------------------------------- /src/client/telemetry/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | 'use strict'; 5 | 6 | 7 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 8 | export type PythonInterpreterTelemetry = any; 9 | -------------------------------------------------------------------------------- /src/client/testing/common/helpers.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | /** 4 | * This function normalizes the provided paths and the existing paths in PYTHONPATH, 5 | * adds the provided paths to PYTHONPATH if they're not already present, 6 | * and then returns the updated PYTHONPATH. 7 | * 8 | * @param newPaths - An array of paths to be added to PYTHONPATH 9 | * @param launchPythonPath - The initial PYTHONPATH 10 | * @returns The updated PYTHONPATH 11 | */ 12 | export function addPathToPythonpath(newPaths: string[], launchPythonPath: string | undefined): string { 13 | // Split PYTHONPATH into array of paths if it exists 14 | let paths: string[]; 15 | if (!launchPythonPath) { 16 | paths = []; 17 | } else { 18 | paths = launchPythonPath.split(path.delimiter); 19 | } 20 | 21 | // Normalize each path in the existing PYTHONPATH 22 | paths = paths.map((p) => path.normalize(p)); 23 | 24 | // Normalize each new path and add it to PYTHONPATH if it's not already present 25 | newPaths.forEach((newPath) => { 26 | const normalizedNewPath: string = path.normalize(newPath); 27 | 28 | if (!paths.includes(normalizedNewPath)) { 29 | paths.push(normalizedNewPath); 30 | } 31 | }); 32 | 33 | // Join the paths with ':' to create the updated PYTHONPATH 34 | const updatedPythonPath: string = paths.join(path.delimiter); 35 | 36 | return updatedPythonPath; 37 | } 38 | -------------------------------------------------------------------------------- /src/client/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export type IStartupDurations = Record< 5 | 'totalNonBlockingActivateTime' | 'totalActivateTime' | 'startActivateTime' | 'codeLoadingTime', 6 | number 7 | >; 8 | -------------------------------------------------------------------------------- /src/environments/cache.ts: -------------------------------------------------------------------------------- 1 | import { commands, ExtensionContext, ExtensionMode } from 'vscode'; 2 | import { PythonEnvironment } from '../client/pythonEnvironments/info'; 3 | 4 | const LastExtensionVersionKey = 'LAST_EXTENSION_VERSION'; 5 | export const EnvironmentsCacheMementoKey = 'PYTHON:PACKAGE_MANAGER:ENVS_CACHE'; 6 | 7 | let cacheClearedOnce = false; 8 | export async function clearCacheIfNewVersionInstalled(context: ExtensionContext, clearEnvCache = false) { 9 | const shouldRefresh = context.extensionMode === ExtensionMode.Development; 10 | if (!shouldRefresh && (cacheClearedOnce || context.globalState.get(LastExtensionVersionKey, '') === context.extension?.packageJSON?.version)) { 11 | return; 12 | } 13 | cacheClearedOnce = true; 14 | let venvEnvs: PythonEnvironment[] = [] 15 | if (!clearEnvCache) { 16 | venvEnvs = context.globalState.get(EnvironmentsCacheMementoKey, []); 17 | } 18 | 19 | await Promise.all([ 20 | commands.executeCommand('python.envManager.clearPersistentStorage'), 21 | context.globalState.keys().filter(key => key !== LastExtensionVersionKey).map(key => context.globalState.update(key, undefined)), 22 | context.workspaceState.keys().map(key => context.workspaceState.update(key, undefined)) 23 | ]); 24 | await context.globalState.update(LastExtensionVersionKey, context.extension.packageJSON.version); 25 | if (!clearEnvCache && Array.isArray(venvEnvs)) { 26 | await context.globalState.update(EnvironmentsCacheMementoKey, venvEnvs); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/environments/constants.ts: -------------------------------------------------------------------------------- 1 | import { window } from 'vscode'; 2 | 3 | export const loggingOutputChannel = window.createOutputChannel('Python Environments (logging)'); 4 | -------------------------------------------------------------------------------- /src/environments/environments.ts: -------------------------------------------------------------------------------- 1 | import { EnvironmentType } from '../client/pythonEnvironments/info'; 2 | 3 | export type RefreshUntilNewEnvIsAvailable = (options: { name?: string; path?: string; type: EnvironmentType }) => Promise; 4 | -------------------------------------------------------------------------------- /src/environments/micromamba/constants.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import { getOSType, getUserHomeDir, OSType } from '../../client/common/utils/platform'; 3 | import { home } from '../helpers'; 4 | 5 | export const MICROMAMBA_ROOTPREFIX = path.join(getUserHomeDir() || home, 'micromamba'); 6 | export const MICROMAMBA_DIR = path.join(getUserHomeDir() || home, '.micromamba'); 7 | export const MICROMAMBA_BASE_ENV_NAME = 'micromambaBase'; 8 | export const CONDA_EXE = path.join(MICROMAMBA_ROOTPREFIX, 'condabin', getOSType() === OSType.Windows ? 'conda.exe' : 'conda'); 9 | export const MICROMAMBA_EXE = path.join(MICROMAMBA_DIR, 'bin', getOSType() === OSType.Windows ? 'micromamba.exe' : 'micromamba'); 10 | export const BASE_MICROMAMBA_PYTHON_EXE = path.join(MICROMAMBA_ROOTPREFIX, getOSType() === OSType.Windows ? 'Scripts' : 'bin', getOSType() === OSType.Windows ? 'python.exe' : 'python'); 11 | -------------------------------------------------------------------------------- /src/environments/sillyDI.ts: -------------------------------------------------------------------------------- 1 | // For inversify to work we must have at lest one class that binds to an interface 2 | 3 | import { injectable } from 'inversify'; 4 | import { IExtensionActivationService } from '../client/activation/types'; 5 | import { Resource } from '../client/common/types'; 6 | 7 | @injectable() 8 | export class Dummy implements IExtensionActivationService { 9 | supportedWorkspaceTypes: { untrustedWorkspace: boolean; virtualWorkspace: boolean; } = { untrustedWorkspace: false, virtualWorkspace: false }; 10 | async activate(_resource: Resource): Promise { 11 | // 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "module": "commonjs", 5 | "target": "es6", 6 | "outDir": "out", 7 | "lib": [ 8 | "es6", 9 | "es2018", 10 | "ES2019", 11 | "ES2020", 12 | ], 13 | "sourceMap": true, 14 | "rootDir": "src", 15 | "experimentalDecorators": true, 16 | "allowSyntheticDefaultImports": true, 17 | "noImplicitThis": false 18 | }, 19 | "exclude": [ 20 | "node_modules", 21 | ".vscode-test", 22 | ".vscode test", 23 | "build" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "*": ["types/*"] 6 | }, 7 | "module": "commonjs", 8 | "target": "es2018", 9 | "outDir": "out", 10 | "lib": [ 11 | "es6", 12 | "es2018", 13 | "dom", 14 | "ES2019", 15 | "ES2020" 16 | ], 17 | "sourceMap": true, 18 | "rootDir": "src", 19 | "experimentalDecorators": true, 20 | "allowSyntheticDefaultImports": true, 21 | "strict": true, 22 | "noImplicitAny": true, 23 | "noImplicitThis": true, 24 | "noUnusedLocals": true, 25 | "noUnusedParameters": true, 26 | "noFallthroughCasesInSwitch": true, 27 | "resolveJsonModule": true, 28 | "removeComments": true 29 | }, 30 | "exclude": [ 31 | ".vscode-test", 32 | ".vscode test", 33 | "src/server/node_modules", 34 | "src/client/node_modules", 35 | "src/server/src/typings", 36 | "src/client/src/typings", 37 | "src/smoke", 38 | "build", 39 | "out", 40 | "tmp" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /tsfmt.json: -------------------------------------------------------------------------------- 1 | { 2 | "tabSize": 4, 3 | "indentSize": 4, 4 | "newLineCharacter": "\n", 5 | "convertTabsToSpaces": false, 6 | "insertSpaceAfterCommaDelimiter": true, 7 | "insertSpaceAfterSemicolonInForStatements": true, 8 | "insertSpaceBeforeAndAfterBinaryOperators": true, 9 | "insertSpaceAfterKeywordsInControlFlowStatements": true, 10 | "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, 11 | "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, 12 | "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, 13 | "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, 14 | "insertSpaceBeforeFunctionParenthesis": false, 15 | "placeOpenBraceOnNewLineForFunctions": false, 16 | "placeOpenBraceOnNewLineForControlBlocks": false 17 | } 18 | -------------------------------------------------------------------------------- /types/vscode.proposed.envShellEvent.d.ts: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | declare module 'vscode' { 7 | 8 | // See https://github.com/microsoft/vscode/issues/160694 9 | export namespace env { 10 | 11 | /** 12 | * An {@link Event} which fires when the default shell changes. 13 | */ 14 | export const onDidChangeShell: Event; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /typings/dom.fix.rx.compiler.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /** 5 | * These are fake dom type definitions that rxjs depends on. 6 | * Another solution is to add the 'dom' lib to tsconfig, but that's even worse. 7 | * We don't need dom, as the extension does nothing with the dom (dom = HTML entities and the like). 8 | */ 9 | 10 | interface EventTarget { } 11 | interface NodeList { } 12 | interface HTMLCollection { } 13 | interface XMLHttpRequest { } 14 | interface Event { } 15 | interface MessageEvent { } 16 | interface CloseEvent { } 17 | interface WebSocket { } 18 | -------------------------------------------------------------------------------- /typings/extensions.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /** 5 | * @typedef {Object} SplitLinesOptions 6 | * @property {boolean} [trim=true] - Whether to trim the lines. 7 | * @property {boolean} [removeEmptyEntries=true] - Whether to remove empty entries. 8 | */ 9 | 10 | // https://stackoverflow.com/questions/39877156/how-to-extend-string-prototype-and-use-it-next-in-typescript 11 | 12 | declare interface String { 13 | /** 14 | * Appropriately formats a string so it can be used as an argument for a command in a shell. 15 | * E.g. if an argument contains a space, then it will be enclosed within double quotes. 16 | */ 17 | toCommandArgumentForPythonMgrExt(): string; 18 | /** 19 | * Appropriately formats a a file path so it can be used as an argument for a command in a shell. 20 | * E.g. if an argument contains a space, then it will be enclosed within double quotes. 21 | */ 22 | fileToCommandArgumentForPythonMgrExt(): string; 23 | } 24 | 25 | declare interface Promise { 26 | /** 27 | * Catches task errors and ignores them. 28 | */ 29 | ignoreErrors(): Promise; 30 | } 31 | -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | // Added to allow compilation of backbone types pulled in from ipywidgets (@jupyterlab/widgets). 5 | declare namespace JQuery { 6 | type TriggeredEvent = unknown; 7 | } 8 | -------------------------------------------------------------------------------- /typings/vscode-proposed/index.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* eslint-disable */ 5 | 6 | /* Proposed APIS can go here */ 7 | -------------------------------------------------------------------------------- /typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | declare module 'vscode' { 7 | 8 | // https://github.com/microsoft/vscode/issues/73904 9 | 10 | export interface QuickPickItem { 11 | /** 12 | * An optional flag to sort the final results by index of first query match in label. Defaults to true. 13 | */ 14 | tooltip?: string | MarkdownString; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /typings/vscode-proposed/vscode.proposed.saveEditor.d.ts: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | // https://github.com/microsoft/vscode/issues/178713 7 | 8 | declare module 'vscode' { 9 | 10 | export namespace workspace { 11 | 12 | /** 13 | * Saves the editor identified by the given resource and returns the resulting resource or `undefined` 14 | * if save was not successful. 15 | * 16 | * **Note** that an editor with the provided resource must be opened in order to be saved. 17 | * 18 | * @param uri the associated uri for the opened editor to save. 19 | * @return A thenable that resolves when the save operation has finished. 20 | */ 21 | export function save(uri: Uri): Thenable; 22 | 23 | /** 24 | * Saves the editor identified by the given resource to a new file name as provided by the user and 25 | * returns the resulting resource or `undefined` if save was not successful or cancelled. 26 | * 27 | * **Note** that an editor with the provided resource must be opened in order to be saved as. 28 | * 29 | * @param uri the associated uri for the opened editor to save as. 30 | * @return A thenable that resolves when the save-as operation has finished. 31 | */ 32 | export function saveAs(uri: Uri): Thenable; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /typings/webworker.fix.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | // Fake interfaces that are required for web workers to work around 5 | // tsconfig's DOM and WebWorker lib options being mutally exclusive. 6 | // https://github.com/microsoft/TypeScript/issues/20595 7 | 8 | interface DedicatedWorkerGlobalScope {} 9 | --------------------------------------------------------------------------------