mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Catch some cases were _sqlite3.Connection was misidentified as sqlite3.Connection
This commit is contained in:
@@ -386,6 +386,21 @@ class DirectObjectAccess(object):
|
|||||||
if inspect.ismodule(return_obj):
|
if inspect.ismodule(return_obj):
|
||||||
return [access]
|
return [access]
|
||||||
|
|
||||||
|
try:
|
||||||
|
module = return_obj.__module__
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
__import__(module)
|
||||||
|
# For some modules like _sqlite3, the __module__ for classes is
|
||||||
|
# different, in this case it's sqlite3. So we have to try to
|
||||||
|
# load that "original" module, because it's not loaded yet. If
|
||||||
|
# we don't do that, we don't really have a "parent" module and
|
||||||
|
# we would fall back to builtins.
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
module = inspect.getmodule(return_obj)
|
module = inspect.getmodule(return_obj)
|
||||||
if module is None:
|
if module is None:
|
||||||
module = inspect.getmodule(type(return_obj))
|
module = inspect.getmodule(type(return_obj))
|
||||||
|
|||||||
16
test/test_inference/test_gradual/test_conversion.py
Normal file
16
test/test_inference/test_gradual/test_conversion.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from os.path import join
|
||||||
|
|
||||||
|
from jedi.inference.gradual.conversion import convert_names
|
||||||
|
|
||||||
|
|
||||||
|
def test_sqlite3_conversion(Script):
|
||||||
|
script1 = Script('import sqlite3; sqlite3.Connection')
|
||||||
|
d, = script1.goto_definitions()
|
||||||
|
|
||||||
|
assert not d.module_path
|
||||||
|
assert d.full_name == 'sqlite3.Connection'
|
||||||
|
assert convert_names([d._name], only_stubs=True)
|
||||||
|
|
||||||
|
d, = script1.goto_definitions(only_stubs=True)
|
||||||
|
assert d.is_stub()
|
||||||
|
assert d.full_name == 'sqlite3.dbapi2.Connection'
|
||||||
Reference in New Issue
Block a user