Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Rename symbol fails with assert statements  #2057

@ehatton

Description

@ehatton

Environment data

  • VS Code version: 1.45.1
  • Extension version (available under the Extensions sidebar): 2020.5.80290
  • OS and version: Windows_NT x64 10.0.18363
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.2 Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: n/a
  • Relevant/affected Python-related VS Code extensions and their versions: n/a
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): Language Server
  • Value of the python.languageServer setting: Microsoft

Steps to reproduce:

  1. Create a file containing the following code in a new project directory:
class Foo:
    def __init__(self):
        self.foo = "test"


f = Foo()
assert f.foo == "test"
print(f.foo)
  1. Wait for python extension to finish loading.
  2. Put cursor on the foo attribute in line 3 and press F2, rename symbol to "bar".

Expected behaviour

The foo attribute is renamed on lines 3, 7 and 8.

Actual behaviour

The foo attribute is only renamed on lines 3 and 8, but not in the assert statement on line 7, see screenshot below:

image

I noticed this bug while trying to refactor some code which uses pytest for testing (hence lots of assert statements). It seems to only affect class attributes and not variables.

Logs

User belongs to experiment group 'AlwaysDisplayTestExplorer - experiment'
User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'LS - enabled'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'AA_testing - control'
User belongs to experiment group 'WebHostNotebook - control'
User belongs to experiment group 'LocalZMQKernel - control'
User belongs to experiment group 'NativeNotebook - control'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'RunByLine - control'
> conda --version
> pyenv root
> python3.7 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3.7 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3.6 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -2 c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~\Anaconda3\envs\test\python.exe c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~\Anaconda3\Scripts\conda.exe info --json
> ~\Anaconda3\Scripts\conda.exe info --json
> ~\Anaconda3\Scripts\conda.exe info --json
> ~\Anaconda3\Scripts\conda.exe info --json
> ~\Anaconda3\Scripts\conda.exe env list
Starting Microsoft Python language server.
Python interpreter path: ~\Anaconda3\envs\test\python.exe
> ~\Anaconda3\Scripts\conda.exe info --json
> ~\Anaconda3\Scripts\conda.exe env list
> ~\Anaconda3\python.exe c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import notebook"
> ~\Anaconda3\python.exe c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import jupyter"
> ~\Anaconda3\python.exe c:\Users\ehatt\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py jupyter kernelspec --version
> ~\Anaconda3\Scripts\black.exe --diff --quiet c:\Users\ehatt\python\test\foo.py.c4d40c94ec4e3f4618d37f360ff6e3bc.py
cwd: c:\Users\ehatt\python\test
> ~\Anaconda3\Scripts\black.exe --diff --quiet c:\Users\ehatt\python\test\foo.py.c4d40c94ec4e3f4618d37f360ff6e3bc.py
cwd: c:\Users\ehatt\python\test
> ~\Anaconda3\Scripts\black.exe --diff --quiet c:\Users\ehatt\python\test\foo.py.c4d40c94ec4e3f4618d37f360ff6e3bc.py
cwd: c:\Users\ehatt\python\test


Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

XXXX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions