Comments (11)
This works for me (both with current beta as well as with the dev branch).
>>> jedi.Script(u'import json\njson.l', 2, len('json.l'), '').complete()
[<Completion: loads>, <Completion: load>]
I'm on Arch Linux with Python 2.7.3. Can you post your system configuration?
from jedi.
Python 2.7.2+ on Ubuntu 11.10
from jedi.
Ah, and tested against both dev branch and 0.5b3
from jedi.
I can reproduce this also in Python 2.6.7
from jedi.
I think this is because of some fix between Python 2.7.2 and 2.7.3, as test of Emacs Jedi with Python 2.7.3 is passing in Travis CI but the same test with Python 2.7.2 fails in my desktop. Also the same test with Python 2.6 in Travis CI fails.
https://travis-ci.org/#!/tkf/emacs-jedi/builds/3027374
from jedi.
You're right, I can reproduce this with Python 2.6.8...
I tried to debug this, but don't understand Jedi enough yet to find the bug. All I found was that under Python 2.6, scopes is an empty list while under Python 2.7.3 it contains <Module: /usr/lib/python2.7/json/__init__.py@1-None>
.
from jedi.
Could you try the same thing with a str cast?
I'm already doing some strange things with strings, where I'm not entirely sure what's happening:
https://github.com/davidhalter/jedi/blob/master/jedi/_compatibility.py#L81
Could be this change:
- Issue #1548891: The cStringIO.StringIO() constructor now encodes unicode
arguments with the system default encoding just like the write() method
does, instead of converting it to a raw buffer. This also fixes handling of
unicode input in the shlex module (#6988, #1170).
Found in: http://hg.python.org/cpython/file/d46c1973d3c4/Misc/NEWS
from jedi.
Your code in https://github.com/davidhalter/jedi/blob/master/jedi/_compatibility.py#L81
# BytesIO (Python 2.5 has no io module)
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
Shouldn't this be other way around, like this?:
try:
from io import BytesIO
except ImportError:
from cStringIO import StringIO as BytesIO
The current code imports BytesIO.io only in Python3 where cStringIO does not exist.
So, in Python 2.6/2.7:
% python -c 'import jedi; print jedi._compatibility.BytesIO'
<built-in function StringIO>
Python 3.2
% cd jedi
% python3 -c 'import _compatibility; print(_compatibility.BytesIO)'
<class '_io.BytesIO'>
from jedi.
Casting it to str works. I am doing source.encode()
before passing it to Jedi.source
for Python 2.x
from jedi.
BTW: I'm still struggling with that:
http://bugs.python.org/issue12486
from jedi.
Thanks for the fix! I can confirm that completion works with str and unicode in Python 2.6 and 2.7.
from jedi.
Related Issues (20)
- Python stubs loaded from extensions folder even when using an explicit interpreter HOT 8
- Error when trying to detect environment HOT 5
- `PathFinder` has no attribute `find_module` in `python 12.2` HOT 2
- Questions about Copilot + Open Source Software Hierarchy HOT 1
- What exactly does "smart_sys_path" do? HOT 5
- Completion fails when variable name is identical to type name HOT 4
- 'TreeInstance' object has no attribute 'with_generics' when using typing.Literal["str"] return annotation on property HOT 4
- How to discover the import statement for a particular Name? HOT 4
- Does Jedi support type inference for type annotations that include generics? HOT 2
- _get_executable_path() can't get the correct path on Windows Anaconda
- Issues with pytest 8 HOT 1
- [Feature request] Support for syntax coloring (based on symbol type) HOT 1
- Script.infer() unexpectedly returns empty list HOT 10
- Jedi outputs: Syntax Error Invalid Syntax HOT 2
- [Feature Request]: infer the return type of functions HOT 1
- Any type inference error HOT 6
- `test_completion_param_annotations` fails in Python 3.13 HOT 4
- jedi automatic completion missing HOT 9
- Vendored `typeshed` is totally obsolete HOT 1
- Rhs in the form of "x" in "xxx" cannot infer the type HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jedi.