Autocompletion etc.

PyCharm have a lot of nice features. But some of them are only usable for standard functions/objects. Let's look at example (django).

I have my own generic view:

def my_nice_generic_view(request, template_name, **kwargs):

    # code

    # code

    # more awesome code

    return render_to_response(template_name, {...some variables ...}, RequestContext(request))

Now, if I i'm using it in other views or directly in urlconf, PyCharm doesn't know that argument template_name of view my_nice_generic_view is a template. So it doesn't support navigation to template. It makes "navigate to template" feature useless in views that use my_nice_generic_view.

We all know, that PyCharm is not able to recognize all constructions like that. It also applies to autocompletion (arguments, return values) and etc. I think there should be ability for users to write simple rules to "help" PyCharm.

There could be an option to write some rules in docstrings. Syntax? I don't know, maybe similar to epydoc. In this case (docstrings) there still should be an option to write those rules in some special file, so we can write them for files outside of project (like 3rd party libraries). This would be very useful, because community could take care of things like "navigate to template in x or y generic view" and programmers will have much more time for implementing new features :-)

How it could look like:

def my_nice_generic_view(request, template_name, **kwargs):

    u"""

    Docs, docs, docs

   

    @type request: django.http.HttpRequest

    @type template_name: string

    @param template_name: Template name (PyCharm:TEMPLATE_NAME)

    """

    # code

    # code

    # more awesome code

    return render_to_response(template_name, {...some variables ...}, RequestContext(request))

This is just an idea. If you like it, we should start a discussion on how it should look like. And sorry for my english ;]

4 comments
Comment actions Permalink

Hello Say,

Could you please file a feature request in YouTrack?

In any case, I have to say that it won't be a high-priority feature: from

our experience, the majority of IDE users are unwilling to put things in

their code only for the sake of helping the IDE navigate around the codebase,

so most people will not use this functionality.

PyCharm have a lot of nice features. But some of them are only usable

for standard functions/objects. Let's look at example (django).

I have my own generic view:

def my_nice_generic_view(request, template_name, **kwargs):

  1. code

  2. code

  3. more awesome code

return render_to_response(template_name, {...some variables ...},

RequestContext(request))

Now, if I i'm using it in other views or directly in urlconf, PyCharm

doesn't know that argument template_name of view my_nice_generic_view

is a template. So it doesn't support navigation to template. It makes

"navigate to template" feature useless in views that use

my_nice_generic_view.

We all know, that PyCharm is not able to recognize all constructions

like that. It also applies to autocompletion (arguments, return

values) and etc. I think there should be ability for users to write

simple rules to "help" PyCharm.

There could be an option to write some rules in docstrings. Syntax? I

don't know, maybe similar to epydoc. In this case (docstrings) there

still should be an option to write those rules in some special file,

so we can write them for files outside of project (like 3rd party

libraries). This would be very useful, because community could take

care of things like "navigate to template in x or y generic view" and

programmers will have much more time for implementing new features

:-)

How it could look like:

def my_nice_generic_view(request, template_name, **kwargs):

u"""

Docs, docs, docs

@type request: django.http.HttpRequest

@type template_name: string

@param template_name: Template name (PyCharm:TEMPLATE_NAME)

"""

  1. code

  2. code

  3. more awesome code

return render_to_response(template_name, {...some variables ...},

RequestContext(request))

This is just an idea. If you like it, we should start a discussion on

how it should look like. And sorry for my english ;]

---

Original message URL:

http://devnet.jetbrains.net/message/5266165#5266165

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0
Comment actions Permalink

I observed that at least the EAP version of PyCharm is able to dectect param types but I have no idea how am I supposed to enable it because it doen't work all the time.

The feature seems to be called "inferred type", but how do I have to write the code in order to assure it will work?

0
Comment actions Permalink

As far as I know the correct syntax for doxygen style comments should be something like

def myfunc(param_name):

## some desc

# @param param_name param_type description

# @return return_type description

Still doxygen is currently not able to properly recognize param_type inside Python code but if the param type is class-type (has at least one uppercase letter) it will hyperlink it.

0

Please sign in to leave a comment.