PyCharm 5.1 EAP 144.4199.7: Python 2/3 compatible type hinting, Postfix Completion, Terminal Improvements

Posted on by Dmitry Filippov

A week ago we announced the first PyCharm 5.1 EAP build with lots of new neat features and improvements such as Tox support, Optional PyPI repositories, Debugger performance improvements and more. Today we continue the weekly delivery of PyCharm 5.1 preview builds with the PyCharm 5.1 EAP build 144.4199.7.
Download and try it today!

Let’s look at the set of valuable improvements introduced in this build.

Python 2 and Python 3 Compatible Type Hinting

With its release half a year ago, Python 3.5 introduced type hinting to help code-writing during development. The standard that brings optional type hinting to Python is PEP 484. PyCharm fully supported this standard with the PyCharm 5 release along with the full support for other new Python 3.5 standards.

Recently an addition to PEP 484 has been proposed to make type hinting possible in Python 2/3 compatible code. The addition has been accepted and can be found in PEP 484 | Suggested syntax for Python 2.7 and straddling code. With PyCharm 5.1 we bring support for this valuable addition for both Python 2 and 3:

python27

Please read this comprehensive blog post on Python 3.5 type hinting in PyCharm 5 to get a better idea of what type hinting is in Python and why it’s important.

Postfix Code Completion

Postfix code completion helps reduce backward caret jumps as you write code. It lets you transform an already typed expression to another one based on the postfix you’ve added and the context of the expression. For example, the “.if” postfix applied to an expression wraps it with an if statement. Likewise the “.ifnn” triggers a surround template checking the expression for the not None value:

postfix

To see all the postfix templates and change their settings (for example, to disable the templates you don’t need), go to Settings → Editor → General → Postfix Templates.

Local Terminal Improvements

Embedded local terminal now supports “Find in text”. Hit Ctrl+F in the terminal and start searching in the terminal output:

terminal

Additionally the terminal now supports double-width unicode characters and is now capable of performing Alt+Backspace for deleting symbols to the left of caret position and Ctrl+Left/Right to move caret to the left or right of the current word.

The full list of changes comparing to the previous EAP build is available in the Release notes.

Please take PyCharm 5.1 EAP build 144.4199.7 for a spin! Should you encounter any problems, please report them to our public tracker.

You can download the build or use the patch-based upgrade to upgrade from within the IDE (from the previous PyCharm 5.1 EAP build only) without a full re-installation. Just make sure you’ve selected the EAP channel in update settings.

PyCharm Team
The Drive to Develop

Comments below can no longer be edited.

17 Responses to PyCharm 5.1 EAP 144.4199.7: Python 2/3 compatible type hinting, Postfix Completion, Terminal Improvements

  1. James says:

    February 19, 2016

    One of the little improvements I am loving so far is the Font Ligature support, so Firacode is easy to use and looks very pretty.

  2. Val says:

    February 20, 2016

    I read the link about why type hinting is important, but it’s all about the Python 3 syntax. I don’t understand the point of it if you have to put it in a comment on a separate from the actual parameter list.

    Python 2 compatible type hints (i.e., comments) are not just ignored by the runtime, but syntactically separated from the code they describe. That means it’s just another thing that’s going to get out of sync. I’ll try to maintain it in my program at work, because I care about every line in the repository, but my coworkers will invariably mess it up. Wrong documentation is worse than no documentation.

    I could write a bunch of comprehensive unit tests for all the types in every interface in the system, but that sounds like the worst of both worlds (static typing = more work up-front but type checks are free, and dynamic typing = less work up-front but you have to write tests if you want anything type-checked).

    Redundant information in separate places that has to be maintained by humans is a terrible idea. I’ve seen people fight against this, across the decades, under such names as “SSOT”, “OAOO”, and most recently “DRY”. How many more names do we need before the industry realizes this is a real problem?

    Let’s let Python 2 die already. The Python 2/3-compatible type hint syntax is everything that’s wrong with dynamic languages. Python 3 has type hints done right. Half the Python libraries on Github already can’t maintain their READMEs or docstrings. Now we’re giving them yet another axis upon which to shoot us poor users in the foot.

    • Paul Everitt says:

      February 23, 2016

      I am certainly sympathetic to the overall point you are making: documentation and type hints are artifacts that add work. And if the work isn’t done, they bitrot and thus add confusion.

      However, some library developers want to help their users. So they are willing to do the work. Type hinting might turn out the same.

      Ditto, some library developers want to support Python 2 users. (By some, I mean the vast majority.) They don’t agree that Python 2 should die. This PEP, and this PyCharm feature, is for them.

      Fortunately, for the most part, you should be able to ignore all of this, as it is optional. You can skip documentation, ugly type hinting syntax, and Python 2 for your projects, and not have those choices foisted on you. You’re right that it is another axis, but really…if you are relying on a GitHub repo that can’t get a README right, then you’re likely to get burned in the code itself.

    • Evgeny says:

      February 23, 2016

      I totally agree that having type hints in comments is an easy way to get them out of sync. Unfortunately, there are still people working on big projects written on Python 2. And as bad as this type hinting syntax is, it’s still so much better than not having them at all. They are beneficial during development time (so IDE can quickly provide you with full autocompletion support and show warnings for “incompatible” types) and build time (there are tools like MyPy that can be run to perform the type checking on your source code and report any type mismatch).

  3. ILYA says:

    February 20, 2016

    Can you please tell if this release include this fix:
    https://youtrack.jetbrains.com/issue/WI-674

    • Dmitry Filippov says:

      February 23, 2016

      The fix should be in the build

  4. Phil says:

    February 21, 2016

    Will PyCharm ever have a drag & drop GUI builder? I think it will be a great addition. You can make it so that you can switch between design (drag & drop) and code (the actual Python code being generated in the background (kind of like Android Studio). It can support multiple different GUI libs, like Tkinter, Gtk, Kivy etc. This is a highly requested feature, and will be useful forany developers. Please do it 😉

    • Dmitry Filippov says:

      February 23, 2016

      Currently we don’t have such plans, however we’ll consider this with the next release planning.

      • Andy Hernandez says:

        September 19, 2017

        PyCharm drag & drop GUI builder!!!

        That will be awesome!!

  5. Evgeny says:

    February 23, 2016

    Thanks for your work!
    Is there a way to try this with IDEA installation?

  6. Aaron says:

    February 24, 2016

    There is no menu item called “Settings”. In the menu item called “Default Settings” under “Editor” there is no entry called “General”. How can I access postfix settings in PyCharm 5.0.4?

    • Dmitry Filippov says:

      February 24, 2016

      1. Go to File | Settings (Preferences for Mac OS X).
      2. You can use the search field to look for “postfix” it will show you “Postfix Completion” under Editor | General | Postfix completion.
      Alternatively in the editor hit Ctrl (cmd) + Shift + A and type “postfix”. It will offer you to navigate to the actual settings menu.

  7. Python дайджест# 6: EuroPython 2016 : IT лента новостей ⋆ iAMX - Развлекательно-информационный портал says:

    February 26, 2016

    […] PyCharm 5.1 EAP 144.4199.7:— Python 2 and Python 3 Compatible Type Hinting;— Postfix Code Completion;— Local Terminal Improvements.— повні реліз ноутс тут. […]

  8. Stewart says:

    February 26, 2016

    Ability to add new Postfix would be useful! The current list for Python especially is small…

    • Liana Bakradze says:

      February 29, 2016

      Hi, Stewart!

      If you have any ideas what postfix templates you’d like to see in PyCharm, please create ticket in our bug tracker https://youtrack.jetbrains.com/issues/PY

  9. Python 2 と型ヒント (Type Hints) - 意識低い開発者のBlog says:

    February 29, 2016

    […] PyCharm 5.1 で Python 2 での型ヒントのサポートが追加される予定です. 記事執筆時点では PyCharm 5.1 の EAP (Early Access Preview) […]

  10. PyCharm 5.1 Beta is available | PyCharm Blog says:

    March 3, 2016

    […] one of our previous EAP builds we introduced Python 2 and Python 3 Compatible Type Hinting […]

Subscribe

Subscribe for updates