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

infer fails on deterministic functions #852

Closed
orSolocate opened this issue Nov 11, 2020 · 1 comment
Closed

infer fails on deterministic functions #852

orSolocate opened this issue Nov 11, 2020 · 1 comment

Comments

@orSolocate
Copy link

When the inferred name is derived from a deterministic function or deterministic class method the infer() function fails.
Could anyone explain or fix this behavior?

Steps to reproduce

For example where the value is supposed to be inferred from class method:

module = astroid.parse(
            """
            class myClass:
                 def __init__(self,A):
                    self.A = A
            myObj=myClass(1)
            B=myObj.A
            """)
next(list(module.body[-1].get_children())[1].infer())
-->Uninferable

while this case is inferable:

module = astroid.parse(
            """
            class myClass:
                 def __init__(self):
                    self.A = 1
            myObj=myClass()
            B=myObj.A
            """)
next(list(module.body[-1].get_children())[1].infer())
--><Const.int l.4 at 0x235fa76ab88>

Current behavior

returns Uninferable

Expected behavior

instead of <Const.int l.4 at 0x235fa76ab88>

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

Python 3.7.7
astroid 2.5.0

@PCManticore
Copy link
Contributor

Hi, thanks for the report. astroid currently cannot follow argument values passed from call sites down to the inference site. In the second case, we are able to infer the value because we know for sure it's an integer as it is passed in the attribute initialisation. That's not the case for the first case though, as the value is passed from the initialisation of the class down to the attributes.

This is a long standing "bug" (or feature request) #142 which is non-trivial to solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants