rope
rope copied to clipboard
Implement type inference for list/set/dict/set/generator comprehension
Describe the bug
Currently, type inference are kinda dodgy when analyzing code containing comprehensions.
To Reproduce
Steps to reproduce the behavior:
- 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']
x_var.get_object().get_type()returns<rope.base.builtins.List at 0x7fa67bed99a0>, while this is a Set comprehension, sox_varshould 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