Skip to content

Commit

Permalink
conditionally import reflect-metadata and fix run without debug (#455)
Browse files Browse the repository at this point in the history
* Conditionally import `reflect-metadata` (fixes #432)
    * Once within the extension  
    * Once within the debugger  
    * Once within the unittests  
* Fully qualify the `path` module (fixes #454)
  • Loading branch information
DonJayamanne committed Dec 19, 2017
1 parent d2340d2 commit 785b093
Show file tree
Hide file tree
Showing 60 changed files with 20 additions and 63 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 0.9.1 (18 December 2017)

* Fixes the compatibility issue with the [Visual Studio Code Tools for AI
](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-ai) extension by conditionally importing `reflect-metadata` [#432](https://github.com/Microsoft/vscode-python/issues/432)
* Display runtime errors encountered when running a python program without debugging [#454](https://github.com/Microsoft/vscode-python/issues/454)

## Version 0.9.0 (14 December 2017)

* Translated the commands to simplified Chinese [#240](https://github.com/Microsoft/vscode-python/pull/240) (thanks [Wai Sui kei](https://github.com/WaiSiuKei))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "python",
"displayName": "Python",
"description": "Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, and more.",
"version": "0.9.0",
"version": "0.9.1",
"publisher": "ms-python",
"author": {
"name": "Microsoft Corporation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def handle_exception(exc_type, exc_value, exc_tb):
tb = traceback.extract_tb(exc_tb)
for i in [0, -1]:
while tb:
frame_file = path.normcase(tb[i][0])
frame_file = os.path.normcase(tb[i][0])
if not any(is_same_py_file(frame_file, f) for f in do_not_debug):
break
del tb[i]
Expand Down
1 change: 0 additions & 1 deletion src/client/common/envFileParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as fs from 'fs-extra';
import 'reflect-metadata';
import { PathUtils } from './platform/pathUtils';
import { EnvironmentVariablesService } from './variables/environment';
import { EnvironmentVariables } from './variables/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/installer/condaInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { inject, injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { ICondaLocatorService, IInterpreterLocatorService, INTERPRETER_LOCATOR_SERVICE, InterpreterType } from '../../interpreter/contracts';
import { CONDA_RELATIVE_PY_PATH } from '../../interpreter/locators/services/conda';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/installer/installer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { inject, injectable, named } from 'inversify';
import * as os from 'os';
import * as path from 'path';
import 'reflect-metadata';
import { ConfigurationTarget, QuickPickItem, Uri, window, workspace } from 'vscode';
import * as vscode from 'vscode';
import { IFormatterHelper } from '../../formatters/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/installer/moduleInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { injectable } from 'inversify';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { IServiceContainer } from '../../ioc/types';
import { PythonSettings } from '../configSettings';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/installer/pipInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { Uri, workspace } from 'vscode';
import { IServiceContainer } from '../../ioc/types';
import { IPythonExecutionFactory } from '../process/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { injectable } from 'inversify';
import 'reflect-metadata';
import { ILogger } from './types';

const PREFIX = 'Python Extension: ';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/persistentState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
'use strict';

import { inject, injectable, named } from 'inversify';
import 'reflect-metadata';
import { Memento } from 'vscode';
import { GLOBAL_MEMENTO, IMemento, IPersistentState, IPersistentStateFactory, WORKSPACE_MEMENTO } from './types';

Expand Down
1 change: 0 additions & 1 deletion src/client/common/platform/pathUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { IPathUtils, IsWindows } from '../types';
import { NON_WINDOWS_PATH_VARIABLE_NAME, WINDOWS_PATH_VARIABLE_NAME } from './constants';

Expand Down
1 change: 0 additions & 1 deletion src/client/common/platform/registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { injectable } from 'inversify';
import 'reflect-metadata';
import * as Registry from 'winreg';
import { Architecture, IRegistry, RegistryHive } from './types';

Expand Down
1 change: 0 additions & 1 deletion src/client/common/process/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import * as iconv from 'iconv-lite';
import { injectable } from 'inversify';
import 'reflect-metadata';
import { DEFAULT_ENCODING } from './constants';
import { IBufferDecoder } from './types';

Expand Down
1 change: 0 additions & 1 deletion src/client/common/process/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { spawn } from 'child_process';
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import * as Rx from 'rxjs';
import { Disposable } from 'vscode';
import { createDeferred } from '../helpers';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/process/pythonExecutionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { PythonSettings } from '../configSettings';
import { IEnvironmentVariablesProvider } from '../variables/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/process/pythonProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { injectable } from 'inversify';
import 'reflect-metadata';
import { ErrorUtils } from '../errors/errorUtils';
import { ModuleNotInstalledError } from '../errors/moduleNotInstalledError';
import { EnvironmentVariables } from '../variables/types';
Expand Down
2 changes: 0 additions & 2 deletions src/client/common/process/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable-next-line:no-import-side-effect
import 'reflect-metadata';
import { IServiceManager } from '../../ioc/types';
import { BufferDecoder } from './decoder';
import { ProcessService } from './proc';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import 'reflect-metadata';
import { IServiceManager } from '../ioc/types';
import { CondaInstaller } from './installer/condaInstaller';
import { Installer } from './installer/installer';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { Disposable, Terminal, Uri, window, workspace } from 'vscode';
import { IServiceContainer } from '../../ioc/types';
import { IDisposableRegistry, IsWindows } from '../types';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/variables/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import * as fs from 'fs-extra';
import { inject, injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { IPathUtils } from '../types';
import { EnvironmentVariables, IEnvironmentVariablesService } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { Disposable, FileSystemWatcher, Uri, workspace } from 'vscode';
import { PythonSettings } from '../configSettings';
import { NON_WINDOWS_PATH_VARIABLE_NAME, WINDOWS_PATH_VARIABLE_NAME } from '../platform/constants';
Expand Down
2 changes: 0 additions & 2 deletions src/client/common/variables/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable-next-line:no-import-side-effect
import 'reflect-metadata';
import { IServiceManager } from '../../ioc/types';
import { EnvironmentVariablesService } from './environment';
import { EnvironmentVariablesProvider } from './environmentVariablesProvider';
Expand Down
6 changes: 5 additions & 1 deletion src/client/debugger/Main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"use strict";

// This line should always be right on top.
if (Reflect.metadata === undefined) {
// tslint:disable-next-line:no-require-imports no-var-requires
require('reflect-metadata');
}
import * as fs from "fs";
import * as path from "path";
import 'reflect-metadata';
import { DebugSession, Handles, InitializedEvent, OutputEvent, Scope, Source, StackFrame, StoppedEvent, TerminatedEvent, Thread } from "vscode-debugadapter";
import { ThreadEvent } from "vscode-debugadapter";
import { DebugProtocol } from "vscode-debugprotocol";
Expand Down
5 changes: 5 additions & 0 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';
// This line should always be right on top.
if (Reflect.metadata === undefined) {
// tslint:disable-next-line:no-require-imports no-var-requires
require('reflect-metadata');
}
import { Container } from 'inversify';
import * as os from 'os';
import * as vscode from 'vscode';
Expand Down
1 change: 0 additions & 1 deletion src/client/formatters/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { injectable } from 'inversify';
import 'reflect-metadata';
import { IFormattingSettings } from '../common/configSettings';
import { Product } from '../common/types';
import { FormatterId, FormatterSettingsPropertyNames, IFormatterHelper } from './types';
Expand Down
1 change: 0 additions & 1 deletion src/client/formatters/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import 'reflect-metadata';
import { IServiceManager } from '../ioc/types';
import { FormatterHelper } from './helper';
import { IFormatterHelper } from './types';
Expand Down
1 change: 0 additions & 1 deletion src/client/interpreter/interpreterVersion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as child_process from 'child_process';
import { injectable } from 'inversify';
import 'reflect-metadata';
import { getInterpreterVersion } from '../common/utils';
import { IInterpreterVersionService } from './contracts';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { inject, injectable } from 'inversify';
import * as _ from 'lodash';
import * as path from 'path';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { fsExistsAsync, IS_WINDOWS } from '../../../common/utils';
import { IInterpreterLocatorService, IInterpreterVersionService, IKnownSearchPathsForInterpreters, InterpreterType } from '../../contracts';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs-extra';
import { inject, injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { IS_WINDOWS } from '../../../common/configSettings';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as child_process from 'child_process';
import * as fs from 'fs-extra';
import { inject, injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { VersionUtils } from '../../../common/versionUtils';
import { ICondaLocatorService, IInterpreterLocatorService, IInterpreterVersionService, InterpreterType, PythonInterpreter } from '../../contracts';
Expand Down
1 change: 0 additions & 1 deletion src/client/interpreter/locators/services/condaLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as child_process from 'child_process';
import * as fs from 'fs-extra';
import { inject, injectable, named, optional } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { IProcessService } from '../../../common/process/types';
import { IsWindows } from '../../../common/types';
import { VersionUtils } from '../../../common/versionUtils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as child_process from 'child_process';
import { inject, injectable } from 'inversify';
import * as _ from 'lodash';
import * as path from 'path';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { PythonSettings } from '../../../common/configSettings';
import { IInterpreterLocatorService, IInterpreterVersionService, InterpreterType } from '../../contracts';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { inject, injectable } from 'inversify';
import * as _ from 'lodash';
import * as path from 'path';
import 'reflect-metadata';
import { Uri, workspace } from 'vscode';
import { fsReaddirAsync, IS_WINDOWS } from '../../../common/utils';
import { IInterpreterLocatorService, IInterpreterVersionService, IKnownSearchPathsForVirtualEnvironments, InterpreterType, PythonInterpreter } from '../../contracts';
Expand Down
1 change: 0 additions & 1 deletion src/client/interpreter/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import 'reflect-metadata';
import { IsWindows } from '../common/types';
import { IServiceManager } from '../ioc/types';
import {
Expand Down
1 change: 0 additions & 1 deletion src/client/interpreter/virtualEnvs/venv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { fsExistsAsync } from '../../common/utils';
import { InterpreterType } from '../contracts';
import { IVirtualEnvironmentIdentifier } from './types';
Expand Down
1 change: 0 additions & 1 deletion src/client/interpreter/virtualEnvs/virtualEnv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { fsExistsAsync } from '../../common/utils';
import { InterpreterType } from '../contracts';
import { IVirtualEnvironmentIdentifier } from './types';
Expand Down
1 change: 0 additions & 1 deletion src/client/linters/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { ILintingSettings, PythonSettings } from '../common/configSettings';
import { ExecutionInfo, Product } from '../common/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/linters/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import 'reflect-metadata';
import { IServiceManager } from '../ioc/types';
import { LinterHelper } from './helper';
import { ILinterHelper } from './types';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/common/debugLauncher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as getFreePort from 'get-port';
import { inject, injectable } from 'inversify';
import * as os from 'os';
import 'reflect-metadata';
import { debug, Uri, workspace } from 'vscode';
import { PythonSettings } from '../../common/configSettings';
import { IPythonExecutionFactory } from '../../common/process/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/common/services/storageService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { Disposable, Uri, workspace } from 'vscode';
import { IDisposableRegistry } from '../../../common/types';
import { ITestCollectionStorageService, Tests } from './../types';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/common/services/testResultsService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, injectable, named } from 'inversify';
import 'reflect-metadata';
import { TestResultResetVisitor } from './../testVisitors/resultResetVisitor';
import { ITestResultsService, ITestVisitor, TestFile, TestFolder, Tests, TestStatus, TestSuite } from './../types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, injectable, named } from 'inversify';
import 'reflect-metadata';
import { Disposable, OutputChannel, Uri, workspace } from 'vscode';
import { IDisposableRegistry, IOutputChannel } from '../../../common/types';
import { TEST_OUTPUT_CHANNEL } from './../constants';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/common/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { inject, injectable, named } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import * as vscode from 'vscode';
import { Uri, workspace } from 'vscode';
import { window } from 'vscode';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { injectable } from 'inversify';
import 'reflect-metadata';
import { convertFileToPackage } from '../testUtils';
import {
FlattenedTestFunction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { injectable } from 'inversify';
import * as path from 'path';
import 'reflect-metadata';
import { ITestVisitor, TestFile, TestFolder, TestFunction, TestSuite } from '../types';

@injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { injectable } from 'inversify';
import 'reflect-metadata';
import { ITestVisitor, TestFile, TestFolder, TestFunction, TestStatus, TestSuite } from '../types';

@injectable()
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/nosetest/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { Uri } from 'vscode';
import { PythonSettings } from '../../common/configSettings';
import { Product } from '../../common/types';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/nosetest/services/discoveryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { inject, injectable, named } from 'inversify';
import 'reflect-metadata';
import { CancellationTokenSource } from 'vscode';
import { IServiceContainer } from '../../../ioc/types';
import { NOSETEST_PROVIDER } from '../../common/constants';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/nosetest/services/parserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { inject, injectable } from 'inversify';
import * as os from 'os';
import * as path from 'path';
import 'reflect-metadata';
import { convertFileToPackage, extractBetweenDelimiters } from '../../common/testUtils';
import { ITestsHelper, ITestsParser, ParserOptions, TestDiscoveryOptions, TestFile, TestFunction, Tests, TestStatus, TestSuite } from '../../common/types';

Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/pytest/services/discoveryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { inject, injectable, named } from 'inversify';
import 'reflect-metadata';
import { CancellationTokenSource } from 'vscode';
import { IServiceContainer } from '../../../ioc/types';
import { PYTEST_PROVIDER, UNITTEST_PROVIDER } from '../../common/constants';
Expand Down
1 change: 0 additions & 1 deletion src/client/unittests/pytest/services/parserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { inject, injectable } from 'inversify';
import * as os from 'os';
import * as path from 'path';
import 'reflect-metadata';
import { convertFileToPackage, extractBetweenDelimiters } from '../../common/testUtils';
import { ITestsHelper, ITestsParser, ParserOptions, TestDiscoveryOptions, TestFile, TestFunction, Tests, TestStatus, TestSuite } from '../../common/types';

Expand Down
Loading

0 comments on commit 785b093

Please sign in to comment.