Code Monkey home page Code Monkey logo

Comments (8)

davidhalter avatar davidhalter commented on June 21, 2024

That's a good question. Basically you should consider the following code:

if foo:
    def b():
        """ docstr a """
        return 1
else:
    def b():
        """ docstr b """
        return 2.0

b  # <-- goto here

Which function is the right one? Basically there is no valid answer here. a and b should be returned.

In jedi-vim I display a window to let the user choose between the multiple definitions (if there are multiple, if there are not, goto can be performed normally).

from jedi.

dbrgn avatar dbrgn commented on June 21, 2024

That example looks strange. Shouldn't both functions in that example be called def b()? Otherwise there's no ambiguity.

from jedi.

tkf avatar tkf commented on June 21, 2024

I guess you want to put something like this in your code:

if foo:
    def a():
        """ docstr a """
        return 1
    b = a   # <-- this is needed for your argument, right?

But I get your point. I will implement the interface sometime later.

Is it used for inheritance too? For example, something like this:

class A(object):
    def f(self):  # can I go here?
        return 0

class B(A):
    def f(self):
        return super(B, self).f()

b = B()
b.f()  # I want to goto the definition of f

from jedi.

davidhalter avatar davidhalter commented on June 21, 2024

@gwrtheyrn Yeah sure, I edited it. It didn't make sense at all.

@tkf It isn't used for inheritance. Just for multiple declarations of variables. Btw: super isn't working yet. I really want to do it, but I don't have time at the moment.

from jedi.

davidhalter avatar davidhalter commented on June 21, 2024

Can I close?

from jedi.

tkf avatar tkf commented on June 21, 2024

I thought you'd close this by adding the docstring at some point. But yes, I am closing this. Probably I will send PR later to add some docstrings.

from jedi.

davidhalter avatar davidhalter commented on June 21, 2024

Where do you want me to add some docstrings? I don't know what you mean.

from jedi.

tkf avatar tkf commented on June 21, 2024

I mean the docstring of Script.goto and Script.get_definition. You can explain the case when it returns multiple definitions (as illustrated above). Also, I noticed that Script.goto can return the line of from MODULE import FUNCTION instead of def FUNCTION in MODULE.py. You can also explain why is that so.

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.