Giter Club home page Giter Club logo

xontrib-jedi's Introduction

Xonsh Python completions using jedi.

If you like the idea click ⭐ on the repo and tweet.

Installation

To install use pip:

xpip install xontrib-jedi
# or: xpip install -U git+https://github.com/xonsh/xontrib-jedi

Usage

xontrib load jedi

import json
json.<Tab>

Credits

This package was created with xontrib cookiecutter template.

xontrib-jedi's People

Contributors

anki-code avatar jnoortheen avatar teddyhuang-00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

teddyhuang-00

xontrib-jedi's Issues

Failed to load xontrib jedi: module `xonsh.completers` has no attribute `base`

  • Description: This is a regression. I cannot remember clearly which update between Python, xonsh and jedi broke the loading of xontrib jedi. It raises AttributeError: module 'xonsh.completers' has no attribute 'base' then ends loading: Failed to load xontrib jedi.
  • environment:
    • System: macOS, archlinux, ubuntu
    • Python: 3.11.5
    • Xonsh: 0.14.1
    • Xontrib-jedi: 0.0.2
    • jedi: 0.19.0
  • Traceback:
    Traceback (most recent call last):
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 229, in xontribs_load
        update_context(name, ctx=ctx, full_module=full_module)
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 174, in update_context
        modctx = xontrib_context(name, full_module)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 140, in xontrib_context
        module = importlib.import_module(spec.name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/imphooks.py", line 302, in exec_module
        rtn = self.loader.exec_module(module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xontrib/jedi.py", line 163, in <module>
        xonsh.completers.base.complete_python = complete_jedi
        ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'xonsh.completers' has no attribute 'base'
    Traceback (most recent call last):
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 229, in xontribs_load
        update_context(name, ctx=ctx, full_module=full_module)
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 174, in update_context
        modctx = xontrib_context(name, full_module)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 140, in xontrib_context
        module = importlib.import_module(spec.name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/imphooks.py", line 302, in exec_module
        rtn = self.loader.exec_module(module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xontrib/jedi.py", line 163, in <module>
        xonsh.completers.base.complete_python = complete_jedi
        ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'xonsh.completers' has no attribute 'base'
    Traceback (most recent call last):
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 229, in xontribs_load
        update_context(name, ctx=ctx, full_module=full_module)
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 174, in update_context
        modctx = xontrib_context(name, full_module)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 140, in xontrib_context
        module = importlib.import_module(spec.name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/imphooks.py", line 302, in exec_module
        rtn = self.loader.exec_module(module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xontrib/jedi.py", line 163, in <module>
        xonsh.completers.base.complete_python = complete_jedi
        ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'xonsh.completers' has no attribute 'base'
    Traceback (most recent call last):
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 229, in xontribs_load
        update_context(name, ctx=ctx, full_module=full_module)
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 174, in update_context
        modctx = xontrib_context(name, full_module)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 140, in xontrib_context
        module = importlib.import_module(spec.name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/imphooks.py", line 302, in exec_module
        rtn = self.loader.exec_module(module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xontrib/jedi.py", line 163, in <module>
        xonsh.completers.base.complete_python = complete_jedi
        ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'xonsh.completers' has no attribute 'base'
    Traceback (most recent call last):
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 229, in xontribs_load
        update_context(name, ctx=ctx, full_module=full_module)
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 174, in update_context
        modctx = xontrib_context(name, full_module)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 140, in xontrib_context
        module = importlib.import_module(spec.name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/imphooks.py", line 302, in exec_module
        rtn = self.loader.exec_module(module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xontrib/jedi.py", line 163, in <module>
        xonsh.completers.base.complete_python = complete_jedi
        ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'xonsh.completers' has no attribute 'base'
    Traceback (most recent call last):
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 229, in xontribs_load
        update_context(name, ctx=ctx, full_module=full_module)
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 174, in update_context
        modctx = xontrib_context(name, full_module)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/xontribs.py", line 140, in xontrib_context
        module = importlib.import_module(spec.name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/imphooks.py", line 302, in exec_module
        rtn = self.loader.exec_module(module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/teddyhuang/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xontrib/jedi.py", line 163, in <module>
        xonsh.completers.base.complete_python = complete_jedi
        ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'xonsh.completers' has no attribute 'base'
    

Jedi autocomplete mistakes path literals (`p"foo"`) for strings

xonfig

+------------------+--------------------------+
| xonsh            | 0.11.0                   |
| Git SHA          | 4af68065                 |
| Commit Date      | Jan 8 20:16:06 2022      |
| Python           | 3.9.10                   |
| PLY              | 3.11                     |
| have readline    | True                     |
| prompt toolkit   | 3.0.27                   |
| shell type       | prompt_toolkit           |
| history backend  | sqlite                   |
| pygments         | 2.11.2                   |
| on posix         | True                     |
| on linux         | False                    |
| on darwin        | True                     |
| on windows       | False                    |
| on cygwin        | False                    |
| on msys2         | False                    |
| is superuser     | False                    |
| default encoding | utf-8                    |
| xonsh encoding   | utf-8                    |
| encoding errors  | surrogateescape          |
| on jupyter       | False                    |
| jupyter kernel   | None                     |
| xontrib 1        | back2dir                 |
| xontrib 2        | fish_completer           |
| xontrib 3        | jedi                     |
| xontrib 4        | term_integration         |
| RC file 1        | /Users/nicholas/.xonshrc |
+------------------+--------------------------+

Expected Behavior

p".".<TAB> should autocomplete as if it was a pathlib.Path, not a str

Current Behavior

image

I am using Jedi version 0.18.1 (if that makes any difference).

I would be happy to work on a fix if you can point me in the right direction :)

Steps to Reproduce

Install jedi xontrib

Just do p"~/Documents".<TAB> and it will autocomplete like a string instead of a Path

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.