python-language-server icon indicating copy to clipboard operation
python-language-server copied to clipboard

VS Code's "rename symbol" command misbehaves with instance properties

Open gschaffner opened this issue 4 years ago • 0 comments

Environment data

  • Language Server version: 0.5.50.0
  • OS and version: Manjaro GNU/Linux 20.0.3
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.10 (via pyenv-virtualenv)

Expected behaviour

The "rename symbol" command in Code - OSS (VS Code) does not behave properly with instance properties.

Reproduce: With the file below, use "rename symbol" on _n in _n.pi with the new name _np.

import numpy as _n


class something(object):
    def __init__(self, n):
        self._n = n

    @property
    def n(self):
        return self._n * _n.pi

    @n.setter
    def n(self, value):
        self._n = value / _n.pi

The expected result is

import numpy as _np


class something(object):
    def __init__(self, n):
        self._n = n

    @property
    def n(self):
        return self._n * _np.pi

    @n.setter
    def n(self, value):
        self._n = value / _np.pi

Actual behaviour

import numpy as _n


class something(object):
    def __init__(self, n):
        self._np = n

    @property
    def n(self):
        return self._np * _np.pi

    @n.setter
    def n(self, value):
        self._n = value / _np.pi

Additional lnformation

The same misbehavior occurs if import numpy as _n is replaced with _n = object() in the example above.

gschaffner avatar Jun 28 '20 19:06 gschaffner