Code Monkey home page Code Monkey logo

Comments (9)

tkf avatar tkf commented on July 20, 2024

Is it related problem? Type of the class attribute any_re is interpreted as the same as the class itself.:

In [5]:
source = """\
import re

class Spam:
    any_re = re.compile('.*')"""
lines = source.splitlines()
script = jedi.Script(source, len(lines), 5, None)
definition = script.get_definition()
[(d, d.full_name) for d in definition]
Out [5]:
[(<Definition class Spam>, '.Spam'),
 (<Definition class SRE_Pattern>, '_sre.SRE_Pattern')]

For other type such as string, it doesn't occur:

In [7]:
source = """\
s = 'x'"""
lines = source.splitlines()
script = jedi.Script(source, len(lines), 1, None)
definition = script.get_definition()
[(d, d.full_name) for d in definition]
Out [7]:
[(<Definition class str>, '__builtin__.str')]

In [8]:
source = """\
class Spam:
    s = 'x'"""
lines = source.splitlines()
script = jedi.Script(source, len(lines), 5, None)
definition = script.get_definition()
[(d, d.full_name) for d in definition]
Out [8]:
[(<Definition class str>, '__builtin__.str')]

from jedi.

davidhalter avatar davidhalter commented on July 20, 2024

Look at this line: https://bitbucket.org/t0rsten/pep-393/src/4777c4007b5b/Lib/re.py?at=v2.5.1c1#cl-227
This returns the pattern (if it is already in the right form).

I know about this -> Jedi has to understand type(arg). Just give me a while :-)

from jedi.

tkf avatar tkf commented on July 20, 2024

Thanks, I see. How about <Definition class Spam> above? I expect it to be <Definition class str> from your explanation.

from jedi.

davidhalter avatar davidhalter commented on July 20, 2024

That's basically the same problem, I think.

from jedi.

tkf avatar tkf commented on July 20, 2024

Hmm... I guess I need to understand jedi internals to understand this.

from jedi.

davidhalter avatar davidhalter commented on July 20, 2024

Oh, now I know what you mean. I didn't see it before. You're right, that's probably something different. But I'm trying to fix the re.compile bug first. The stuff with Spam seems to be really strange :-)

from jedi.

tkf avatar tkf commented on July 20, 2024

For record, I am using 8ce2633 and Python 2.7. (In case this weird behavior banishes at some point).

from jedi.

davidhalter avatar davidhalter commented on July 20, 2024

It seems like the weird behavior is also gone. I basically just fixed some things to get type to work. But feel free to test again.

from jedi.

tkf avatar tkf commented on July 20, 2024

Wow that was so fast. Thank you very much! I can confirm that the two issues are gone.

from jedi.

Related Issues (20)

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.