From a4007bc5bbff5fa325b6c8660f4f6242f20fb6dd Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Mon, 7 Feb 2022 10:38:26 -0800 Subject: [PATCH 1/2] Use older way of launching debugger when using conda less than 4.9.0 (#18451) --- news/2 Fixes/18436.md | 1 + .../debugger/extension/adapter/factory.ts | 27 ++++++++++++++----- .../common/environmentManagers/conda.ts | 8 ++++++ 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 news/2 Fixes/18436.md diff --git a/news/2 Fixes/18436.md b/news/2 Fixes/18436.md new file mode 100644 index 000000000000..41af906ea823 --- /dev/null +++ b/news/2 Fixes/18436.md @@ -0,0 +1 @@ +Revert to old way of running debugger if conda version less than 4.9.0. diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index 5f69ca1a1bdb..37d2f669a3cf 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -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'; @@ -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"'); @@ -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( @@ -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. @@ -136,10 +143,16 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac return this.getExecutableCommand(interpreters[0]); } + private async getCondaCommand(): Promise { + const condaCommand = await Conda.getConda(); + const isCondaRunSupported = await condaCommand?.isCondaRunSupported(); + return isCondaRunSupported ? condaCommand : undefined; + } + private async getExecutableCommand(interpreter: PythonEnvironment | undefined): Promise { if (interpreter) { if (interpreter.envType === EnvironmentType.Conda) { - const condaCommand = await Conda.getConda(); + const condaCommand = await this.getCondaCommand(); if (condaCommand) { if (interpreter.envName) { return [ diff --git a/src/client/pythonEnvironments/common/environmentManagers/conda.ts b/src/client/pythonEnvironments/common/environmentManagers/conda.ts index c46246ef2017..0db2f81c39d1 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/conda.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/conda.ts @@ -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 { + const condaVersion = await this.getCondaVersion(); + if (condaVersion && lt(condaVersion, CONDA_RUN_VERSION)) { + return false; + } + return true; + } } From 3e7333dd85b740087f5ec4e02d13747ce68aaa2f Mon Sep 17 00:00:00 2001 From: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Date: Fri, 4 Feb 2022 10:36:50 -0800 Subject: [PATCH 2/2] CI failures: Pin prospector to 1.6.0, pytest to < 7.0.0, and fix linting issues with flake8 3.9.2 (#18446) * See if pinning pip works * Pin in pr check * Pin pip everywhere else * angery * Undo pip changes * Pin pytest < 7.0.0 * Fix linting? --- build/test-requirements.txt | 4 +- .../pythonFiles/linting/flake8config/file.py | 49 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/build/test-requirements.txt b/build/test-requirements.txt index d1aad4b75ed4..21e3b5627820 100644 --- a/build/test-requirements.txt +++ b/build/test-requirements.txt @@ -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' diff --git a/src/test/pythonFiles/linting/flake8config/file.py b/src/test/pythonFiles/linting/flake8config/file.py index 047ba0dc679e..9abe4993dddd 100644 --- a/src/test/pythonFiles/linting/flake8config/file.py +++ b/src/test/pythonFiles/linting/flake8config/file.py @@ -2,6 +2,7 @@ __revision__ = None + class Foo(object): """block-disable test""" @@ -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 \ No newline at end of file + print(self.bla) + print(self.blop)