Skip to content

Ufuncs are incompatible with jedi since v1.20.0 #19834

@onatt

Description

@onatt

Since NumPy version 1.20 jedi cannot find some of the NumPy-documentation. This has already been reported and corrected in issue #18859. However, the problem seems to be still persistent for ufuncs. Consequently, many Python IDEs using the language-server-protocol such as Spyder or Emacs with elpy cannot display inline help of these functions.

Reproducing code example:

The following code produces the expected result for the function np.sinc which is not a ufunc.

import numpy
import jedi

code = '''
import numpy as np
np.sinc
'''
pos = {'line': 3, 'column': 4}

script = jedi.Script(code)
result = script.infer(**pos)

print(f'NumPy version: {numpy.__version__}')
print(f'Jedi version: {jedi.__version__}')
print(result)

Result:

NumPy version: 1.21.2
Jedi version: 0.18.0
[<Name full_name='numpy.lib.function_base.sinc', description='def sinc'>]

However, replacing np.sinc by np.sin (which is a ufunc) gives an empty result for the method infer.

import numpy
import jedi

code = '''
import numpy as np
np.sin
'''
pos = {'line': 3, 'column': 4}

script = jedi.Script(code)
result = script.infer(**pos)

print(f'NumPy version: {numpy.__version__}')
print(f'Jedi version: {jedi.__version__}')
print(result)

Result:

NumPy version: 1.21.2
Jedi version: 0.18.0
[]

Exactly the same code yields the expected result for NumPy 1.19.5:

NumPy version: 1.19.5
Jedi version: 0.18.0
[<Name full_name='numpy.sin', description='instance ufunc'>]

Configuration information

The problem seems to be present for all versions of NumPy >= 1.20. As indicated above the problem is also present in NumPy 1.21.2.

Operating-System: Linux 5.13.13
Python: 3.9.6 (default, Jun 30 2021, 10:22:16) [GCC 11.1.0] on linux
NumPy: 1.21.2
Jedi: 0.18.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions