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

Wrong inference maybe due to inference cache #669

Closed
hippo91 opened this issue May 5, 2019 · 2 comments · Fixed by PennyDreadfulMTG/Penny-Dreadful-Tools#8447
Closed
Assignees

Comments

@hippo91
Copy link
Contributor

hippo91 commented May 5, 2019

This bug has been found during the setup of the numpy brains.
Fixing it could improve our inference system for numpy functions.

The directory described hereafter reflects a similar structure inside the numpy sources.

Steps to reproduce

  1. Create a directory named bug_inf with the following structure:
$ tree bug_inf
bug_inf
├── core
│   ├── __init__.py
│   └── shape_base.py
├── __init__.py
└── lib
    ├── __init__.py
    └── shape_base.py
  1. bug_inf/core/__init__.py content is:
$ cat bug_inf/core/__init__.py 
from .shape_base import *
  1. bug_inf/core/shape_base.py content is:
$ cat bug_inf/core/shape_base.py 
def vstack():
    return 42
  1. bug_inf/__init__.py content is:
$ cat bug_inf/__init__.py 
from .core import *
from .lib import *
  1. bug_inf/lib/__init__.py content is:
$ cat bug_inf/lib/__init__.py 
from .shape_base import *
  1. bug_inf/lib/shape_base.py content is:
$ cat bug_inf/lib/shape_base.py 
from bug_inf.core import vstack
  1. Create a file bug_inf.py which content is:
from astroid import extract_node

SRC = """
from bug_inf import vstack
vstack()
"""

NODE = extract_node(SRC)
print(NODE.inferred())
  1. Run python3 bug_inf.py

Current behavior

 $ python3 bug_inf.py 
[<Const.int l.2 at 0x7f08471338d0>, Uninferable]

Expected behavior

 $ python3 bug_inf.py 
[<Const.int l.2 at 0x7f08471338d0>]

Astroid version

python3 -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
2.3.0
@hippo91
Copy link
Contributor Author

hippo91 commented Dec 30, 2019

Here is attached an archive with the files described in the issue.
bug_inf.tar.gz

@hippo91 hippo91 self-assigned this Dec 30, 2019
@hippo91
Copy link
Contributor Author

hippo91 commented Jan 24, 2021

Fixed thanks to PR #884

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