rope icon indicating copy to clipboard operation
rope copied to clipboard

Implement type inference for list/set/dict/set/generator comprehension

Open lieryan opened this issue 4 years ago • 0 comments

Describe the bug

Currently, type inference are kinda dodgy when analyzing code containing comprehensions.

To Reproduce

Steps to reproduce the behavior:

  1. Code to reproduce:
def test_xxx(self):
    code = dedent("""\
        x = {s.strip() for s in ["hello"]}
        x.add('x')
    """)
    self.mod.write(code)
    pymod = self.project.get_pymodule(self.mod)
    x_var = pymod['x']
  1. x_var.get_object().get_type() returns <rope.base.builtins.List at 0x7fa67bed99a0>, while this is a Set comprehension, so x_var should be typed as a Set.

Editor information (please complete the following information):

  • Project Python version: 3.8
  • Rope Python version: 3.8
  • Rope version: 0.21

Additional context

Offshoot bug from #436

lieryan avatar Oct 18 '21 09:10 lieryan