Skip to content

cherry-pick:Use older way of launching debugger when using conda less than 4.9.0 #18465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ yapf
pylint ; python_version > '2.7'
pycodestyle
pydocstyle
prospector ; python_version > '2.7'
pytest ; python_version > '2.7'
prospector>=1.6.0 ; python_version > '2.7'
pytest<7.0.0 ; python_version > '2.7'
flask
fastapi ; python_version > '2.7'
uvicorn ; python_version > '2.7'
Expand Down
1 change: 1 addition & 0 deletions news/2 Fixes/18436.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert to old way of running debugger if conda version less than 4.9.0.
27 changes: 20 additions & 7 deletions src/client/debugger/extension/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { IApplicationShell } from '../../../common/application/types';
import { EXTENSION_ROOT_DIR } from '../../../constants';
import { IInterpreterService } from '../../../interpreter/contracts';
import { traceVerbose } from '../../../logging';
import { traceLog, traceVerbose } from '../../../logging';
import { Conda } from '../../../pythonEnvironments/common/environmentManagers/conda';
import { EnvironmentType, PythonEnvironment } from '../../../pythonEnvironments/info';
import { sendTelemetryEvent } from '../../../telemetry';
Expand Down Expand Up @@ -49,8 +49,14 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac

if (configuration.request === 'attach') {
if (configuration.connect !== undefined) {
traceLog(
`Connecting to DAP Server at: ${configuration.connect.host ?? '127.0.0.1'}:${
configuration.connect.port
}`,
);
return new DebugAdapterServer(configuration.connect.port, configuration.connect.host ?? '127.0.0.1');
} else if (configuration.port !== undefined) {
traceLog(`Connecting to DAP Server at: ${configuration.host ?? '127.0.0.1'}:${configuration.port}`);
return new DebugAdapterServer(configuration.port, configuration.host ?? '127.0.0.1');
} else if (configuration.listen === undefined && configuration.processId === undefined) {
throw new Error('"request":"attach" requires either "connect", "listen", or "processId"');
Expand All @@ -70,10 +76,9 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
const logArgs = configuration.logToFile ? ['--log-dir', EXTENSION_ROOT_DIR] : [];

if (configuration.debugAdapterPath !== undefined) {
return new DebugAdapterExecutable(
executable,
command.concat([configuration.debugAdapterPath, ...logArgs]),
);
const args = command.concat([configuration.debugAdapterPath, ...logArgs]);
traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`);
return new DebugAdapterExecutable(executable, args);
}

const debuggerAdapterPathToUse = path.join(
Expand All @@ -85,8 +90,10 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
'adapter',
);

const args = command.concat([debuggerAdapterPathToUse, ...logArgs]);
traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`);
sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: true });
return new DebugAdapterExecutable(executable, command.concat([debuggerAdapterPathToUse, ...logArgs]));
return new DebugAdapterExecutable(executable, args);
}

// Unlikely scenario.
Expand Down Expand Up @@ -136,10 +143,16 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
return this.getExecutableCommand(interpreters[0]);
}

private async getCondaCommand(): Promise<Conda | undefined> {
const condaCommand = await Conda.getConda();
const isCondaRunSupported = await condaCommand?.isCondaRunSupported();
return isCondaRunSupported ? condaCommand : undefined;
}

private async getExecutableCommand(interpreter: PythonEnvironment | undefined): Promise<string[]> {
if (interpreter) {
if (interpreter.envType === EnvironmentType.Conda) {
const condaCommand = await Conda.getConda();
const condaCommand = await this.getCondaCommand();
if (condaCommand) {
if (interpreter.envName) {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,12 @@ export class Conda {
traceError(`Unable to parse version of Conda, ${versionString}`);
return new SemVer('0.0.1');
}

public async isCondaRunSupported(): Promise<boolean> {
const condaVersion = await this.getCondaVersion();
if (condaVersion && lt(condaVersion, CONDA_RUN_VERSION)) {
return false;
}
return true;
}
}
49 changes: 24 additions & 25 deletions src/test/pythonFiles/linting/flake8config/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__revision__ = None


class Foo(object):
"""block-disable test"""

Expand All @@ -10,78 +11,76 @@ def __init__(self):

def meth1(self, arg):
"""this issues a message"""
print self
print(self)

def meth2(self, arg):
"""and this one not"""
# pylint: disable=unused-argument
print self\
+ "foo"
print(self + "foo")

def meth3(self):
"""test one line disabling"""
# no error
print self.bla # pylint: disable=no-member
print(self.bla) # pylint: disable=no-member
# error
print self.blop
print(self.blop)

def meth4(self):
"""test re-enabling"""
# pylint: disable=no-member
# no error
print self.bla
print self.blop
print(self.bla)
print(self.blop)
# pylint: enable=no-member
# error
print self.blip
print(self.blip)

def meth5(self):
"""test IF sub-block re-enabling"""
# pylint: disable=no-member
# no error
print self.bla
print(self.bla)
if self.blop:
# pylint: enable=no-member
# error
print self.blip
print(self.blip)
else:
# no error
print self.blip
print(self.blip)
# no error
print self.blip
print(self.blip)

def meth6(self):
"""test TRY/EXCEPT sub-block re-enabling"""
# pylint: disable=no-member
# no error
print self.bla
print(self.bla)
try:
# pylint: enable=no-member
# error
print self.blip
except UndefinedName: # pylint: disable=undefined-variable
print(self.blip)
except UndefinedName: # pylint: disable=undefined-variable
# no error
print self.blip
print(self.blip)
# no error
print self.blip
print(self.blip)

def meth7(self):
"""test one line block opening disabling"""
if self.blop: # pylint: disable=no-member
if self.blop: # pylint: disable=no-member
# error
print self.blip
print(self.blip)
else:
# error
print self.blip
print(self.blip)
# error
print self.blip

print(self.blip)

def meth8(self):
"""test late disabling"""
# error
print self.blip
print(self.blip)
# pylint: disable=no-member
# no error
print self.bla
print self.blop
print(self.bla)
print(self.blop)