diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index fba94894..5a9d55c5 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -789,6 +789,13 @@ def _os_path_join(args_set, callback): return callback() +_path_overrides = { + 'dirname': _create_string_input_function(os.path.dirname), + 'abspath': _create_string_input_function(os.path.abspath), + 'relpath': _create_string_input_function(os.path.relpath), + 'join': _os_path_join, +} + _implemented = { 'builtins': { 'getattr': builtins_getattr, @@ -851,12 +858,8 @@ _implemented = { # For now this works at least better than Jedi trying to understand it. 'dataclass': _dataclass }, - 'os.path': { - 'dirname': _create_string_input_function(os.path.dirname), - 'abspath': _create_string_input_function(os.path.abspath), - 'relpath': _create_string_input_function(os.path.relpath), - 'join': _os_path_join, - } + 'posixpath': _path_overrides, + 'ntpath': _path_overrides, } @@ -908,7 +911,8 @@ class EnumInstance(LazyValueWrapper): def tree_name_to_values(func): def wrapper(inference_state, context, tree_name): - if tree_name.value == 'sep' and context.is_module() and context.py__name__() == 'os.path': + if tree_name.value == 'sep' \ + and context.is_module() and context.py__name__() in ('posixpath', 'ntpath'): return ValueSet({ compiled.create_simple_object(inference_state, os.path.sep), }) diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 90fbc0f8..3abd4761 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -210,9 +210,10 @@ def test_chained_calls(Script): def test_return(Script): source = dedent(''' def foo(): - return '.'.join()''') + return (1).conjugate()''') - assert_signature(Script, source, 'join', 0, column=len(" return '.'.join(")) + assert_signature( + Script, source, 'conjugate', expected_index=None, column=len(" return (1).conjugate(")) def test_find_signature_on_module(Script): @@ -249,9 +250,9 @@ def test_complex(Script, environment): # Do these checks just for Python 3, I'm too lazy to deal with this # legacy stuff. ~ dave. assert get_signature(func1.tree_node) \ - == 'compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]' + == 'compile(pattern: AnyStr, flags: _FlagsType = 0) -> Pattern[AnyStr]' assert get_signature(func2.tree_node) \ - == 'compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) ->\nPattern[AnyStr]' + == 'compile(pattern: Pattern[AnyStr], flags: _FlagsType = 0) ->\nPattern[AnyStr]' # jedi-vim #70 s = """def foo("""