Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Yield self when inferring GeneratorExp #1615

Closed

Conversation

jacobtylerwalls
Copy link
Member

Description

import astroid
code = """
def get_generator():
    return (x for x in range(0))
x = get_generator()  #@
if x:
  pass
"""
x = astroid.extract_node(code)
x.value.inferred()

Before: [Uninferable]
Now: [<GeneratorExp l.3 at 0x103e80880>]

Type of Changes

Type
✨ New feature

Related Issue

See pylint-dev/pylint#6909 (comment)

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2480208453

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 92.236%

Totals Coverage Status
Change from base Build 2480015245: 0.003%
Covered Lines: 9362
Relevant Lines: 10150

💛 - Coveralls

@Pierre-Sassoulas Pierre-Sassoulas added the Enhancement ✨ Improvement to a component label Jun 11, 2022
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but looking at the pipeline it seems we're going to get crashes in code that never had to deal with generator expressions before and only handle Uninferable right now.

@jacobtylerwalls
Copy link
Member Author

Yeah, I was looking at that. Most of the other uses of pytype() in pylint are guarded against there being no pytype, there's even a util for it. That one place could be changed to use that util.

However, I realize this is falling afoul of the same issue in #1475 (comment), so I'll be closing. There should be another way in pylint to deal with pylint-dev/pylint#6909 (comment).

@jacobtylerwalls jacobtylerwalls deleted the infer-gen-exp branch June 11, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants