Dynamic runtime type inference in PyCharm 2.7

PyCharm’s debugger is now capable of collecting type information at runtime and using this information for improving code completion suggestions, code insight and quick documentation popups. This needs to be enabled in the debugger settings.

You debug your code all the time, and now in the course of debugging you can also collect type information. Afterwards, it will be used in auto-completion, and you will be able to put the collected type information into docstrings as well. Please note that enabling this feature may affect debugger performance, so use it with care.

For example, let’s consider the following code snippet:

First, make sure that “Collect run-time types information for code insight” is enabled as shown above. Then run the debugger on your code. It doesn’t matter if you use breakpoints or other debugger tools. After the debugger steps into the “foo” method, it will record the types used in the call.

As you develop your code further, you will get suggestions based on this runtime experience. Please note that this will work even during the same debugger session, so you can get suggestions right after the debugger enters any function.

Dynamically collected type information is in use not only inside a function body:

Since PyCharm also makes static type inference, it will guess that “res” will be of the type returned by “foo”:

If different calls to the same function use different argument types, PyCharm will remember all the variants of the types encountered. As always, you can use Quick Documentation Lookup to get quick information on any symbol or just method signature information. Just place the caret on a symbol and press Ctrl+Q:

As you can see, dynamically inferred types are already shown in this popup.

There is also another usage of dynamic type inference: generating docstrings based on information collected by the debugger. The basic steps are the same: enable “Collect run-time types information for code insight” and then debug your method/function. After this, place the caret anywhere within the function body and press Alt+Enter. This displays the “Generate docstrings with types” option. Select it to automatically generate a docstring for your method. For more details please see “Using Docstrings to Specify Types” in Help.

Take advantage of this new feature to better control your source code and improve your user experience with PyCharm.

Develop with pleasure!
JetBrains PyCharm Team

Posted in Cool Feature | 6 Comments

PyCharm 2.7 is available: back to core Python

We’ve released PyCharm 2.7, a big update for our Python and Django IDE.

The main focus of this update is better Python coding experience. We’ve added new code refactorings such as Change Signature and Extract Parameter, and made our code analysis even smarter by using type information collected at runtime during debugging and tests execution. Better PEP 8 integration is now ensured by running pep8.py in the background to show you coding style violations on the fly as you’re editing your code.

Other changes and new features in this update include:

  • General editing improvements such as Unwrap action, Reflow Paragraph, etc.
  • Fresh IDE look and feel, and Darcula, a new native dark UI theme for the IDE and the editor.
  • Vagrant integration and SSH console.
  • Many bugfixes and improvements in the Vim emulation plugin, which can be installed via PyCharm’s plugins manager.
  • Django 1.5 compatibility.
  • Many enhancements for editing JavaScript and CoffeeScript.
  • Syntax highlighting based on TextMate bundles.

Read more about what’s new in PyCharm 2.7 and download the IDE for your platform.

PyCharm 2.7 is a free update for everyone who purchased their license after Feb 7, 2012.
As usual, a 30-day trial is available if you want to try PyCharm as your new Python/Django IDE.

Develop with pleasure!
JetBrains PyCharm Team

Posted in Release Announcements | 26 Comments

PyCharm 2.7 Release Candidate

The work on PyCharm 2.7 proceeds as planned, with the final release just a few days away. Today we’ve published the Release Candidate of PyCharm 2.7, with a number of bugfixes and improvements compared to the Beta build. Especially noteworthy are improvements to the formatter (including several new options in the code style settings), several significant performance improvements and a number of fixes for the inspections and remote interpreters.

As usual, you can read the complete release notes, download the new build from the EAP page, or update from within the IDE. Your feedback is welcome in the issue tracker.

Posted in Uncategorized | Leave a comment

PyCharm 2.7 Beta is available now

We’re happy to announce the release of PyCharm 2.7 Beta – the feature-complete preview version of PyCharm 2.7. Since the previous EAP build, the following features have been added:

  • Settings | Project Dependencies allows you to configure the dependencies between several projects opened in the same PyCharm window.
  • Settings | Remote SSH External Tools allows you to configure external tools that will run on a remote machine over SSH. Just as normal external tools (Settings | External Tools), the remote external tools can be easily accessed from the main menu or context menus.
  • Edit | Refill Paragraph allows to reflow the current string literal, comment or paragraph in a plain text file so that lines of text run up to the right margin but do not exceed it.
  • Shadowing built-ins is a new inspection that highlights definitions of names that match names of Python built-in functions.

We’ve also fixed a long-standing annoyance with PyCharm: namely, the “Comment code” shortcut now follows the PEP 8 requirements and adds the hash sign directly before the text in the line, rather than at column 0, and puts a space after the #.

As usual, you’re welcome to refer to the detailed release notes for more information, and to send your feedback through the issue tracker. The beta build itself is available from the EAP page or as a patch-based upgrade within the IDE.

Posted in Uncategorized | 12 Comments

PyCharm 2.7 EAP 124.571

After a long break (caused mostly by the holidays in Europe and then in Russia), we’re happy to bring you the first PyCharm EAP build for 2013. This build contains most of the features planned for the final 2.7 release – there’s a couple more minor things planned, but for the most part we’re done.

Here’s what’s new:

  • The SSH Console. Once you have a remote interpreter configured, you can use the “Tools | Run SSH Console…” action to open a console connected to the remote machine. PyCharm comes with a pretty complete terminal emulation environment – and you can even run vim in it if you like to.
  • The “Test RESTful Web Service” tool from IntelliJ IDEA is now available in PyCharm and provides an easy to use UI for running HTTP requests against Web services and displaying results returned in XML, JSON and other formats.
  • The “Unwrap/Remove” action, which provides a quick way to remove a control statement surrounding a block of code, is now supported for Python.
  • The Vagrant integration provides an easy way to configure a remote interpreter if you’re using Vagrant to configure your virtual machine.
  • “Extract Variable” and related refactorings can now be invoked on a selected fragment of a string literal, and correctly replace the selected fragment with a formatting operation referencing the extracted variable.

The complete release notes include much more details about the changes in the new build – and by the way, now the release notes include not only issues fixed by the PyCharm team but also all the fixes in IntelliJ Platform and the bundled plugins that affect PyCharm.

As usual, the new build can be downloaded from the EAP page, and the feedback is welcome in the issue tracker.

Posted in Early Access Preview | Leave a comment

PyCharm 2.7 EAP build 124.253

Today we’ve released a new EAP build of PyCharm 2.7. The big new feature in this build is support for syntax highlighting based on TextMate bundles. TextMate bundles (also used by Sublime Text 2) have been created for most of the programming languages and other text file types in use nowadays, and now you can enjoy good quality syntax highlighting when working with those files even if they lack native support in PyCharm.

(Previously you could use PyCharm’s custom file types for this purpose, but they’re quite a bit more limited in capabilities, and there are much fewer custom file type configurations available).

Note that we don’t currently support snippets or menu commands defined in the bundles; bundles are only used for syntax highlighting. It’s possible that the support will be extended in the future.

In addition to that, there’s the usual amount of bugfixes, in areas such as the Django support, test runner, code formatting and others.

As usual, the new build can be downloaded from the EAP page.

Posted in Early Access Preview | Tagged , , , | 23 Comments

PyCharm 2.7 EAP build 124.138

After an unfortunately long delay, today we’ve published a new EAP build of PyCharm 2.7. Noteworthy changes are:

  • The dark look & feel from IntelliJ IDEA 12 is now included and fully supported in PyCharm (Settings | Appearance | Theme | Darcula)
  • Change Signature and Introduce Parameter refactorings are now supported for Python code
  • Vagrant integration makes it much easier to configure a remote interpreter and FTP deployment if you’re using Vagrant to run your development environment in a VM

The development of the IdeaVIM plugin also continues, with a new update published today.

Unfortunately the patch-based upgrade is not available for this build; please download a complete installer from the EAP page. You can also check the release notes for the new build.

Posted in Early Access Preview | Tagged , , , | 6 Comments

Python plugin for IntelliJ IDEA 12 is now available

Just a quick heads up: we’ve just released a version of the Python plugin for the latest Early Access Preview build of IntelliJ IDEA 12 (build 123.4). The plugin includes the entire functionality of the current PyCharm 2.7 EAP, including several features which were previously only available in PyCharm (creating virtualenvs, using remote interpreters, creating UML diagrams for Python code etc.).

As usual, the plugin can be installed from the plugin manager (Settings | Plugins). Note that the support for reStructuredText and .po files is now available as two separate plugins (called “ReStructuredText Support” and “GNU GetText files support (*.po)”). Please install them separately from the plugin manager if you’re using these features in your Python project.

If you run into any problems with the plugin, please don’t hesitate to report them to the issue tracker.

Posted in Release Announcements | Tagged , , | 19 Comments

PyCharm 2.7 Early Access Preview

We’re happy to announce the beginning of the Early Access Preview program for PyCharm 2.7. The new version is focused on improving our support for core Python development and is planned for release before the end of this year. As usual, EAP builds are not feature complete and are likely to contain bugs, but they give you a chance to provide feedback on the new features and ensure that the final production release meets your requirements.

New and noteworthy in this release:

  • PyCharm’s debugger is now capable of collecting type information at runtime and makes use of this information for improving code completion suggestions, code insight and quick documentation popups. This needs to be enabled in the debugger settings.

  • PyCharm now runs pep8.py on the fly as you’re editing the code and highlights the coding style violations. As a quickfix, you can either reformat the file or disable specific types of errors produced by pep8.py.
  • PyCharm now recognizes the Python code in your doctests, provides syntax highlighting and code insight for it, and recognizes the code in doctests when performing other actions (for example, optimizing imports no longer removes imports required by doctests).
  • PyCharm’s test runner now includes a “Rerun failed tests” action.

PyCharm’s users will also benefit from the latest round of improvements in the underlying IntelliJ Platform.

We’d also like to highlight the resumed development of the IdeaVIM plugin, which provides vim keybindings in PyCharm and other IntelliJ-based IDEs. The work up to now was focused on cleaning up the code base, improving test coverage and fixing long-standing bugs and exceptions, but new features will also follow soon. The latest update of IdeaVIM can be installed from Settings | Plugins.

As usual, the new build of PyCharm is available for download on the EAP page, and your feedback is welcome in the issue tracker.

Posted in Early Access Preview | Tagged , , , , | 19 Comments

PyCharm 2.6.3 update available

Today we’ve released the final version of the PyCharm 2.6.3 bugfix update, probably the last one in the 2.6.x series. The list of fixes in this update deals primarily with remote interpreters, diagrams, and test runners. In addition to that, PyCharm includes a large number of IntelliJ Platform fixes related to JavaScript/CoffeeScript, LESS/SASS and other areas.

You can download the build or update from within the IDE.

Posted in Release Announcements | 1 Comment