PyCharm 2021.2: New Python 3.10 Features, HTML Preview: Browser Page Reload on Save, Collaborative Mode in the Python Console
Find out how you can benefit from Python 3.10’s new functionality with PyCharm – even before Python 3.10’s stable release! We started working on support for Python 3.10 by delivering code insight for Explicit Type Aliases (PEP 613) in PyCharm 2020.3. In this release, we have introduced support for even more PEPs.
Structural Pattern Matching is coming in Python 3.10. PyCharm provides a number
of key features to help you adjust to its arrival, like the Unused local symbols
and Unreachable code inspections, smart code completion and syntax highlighting
for the match
and case
keywords, and the
Complete Current Statement action.
PyCharm can now complete match
statements and their corresponding
case
blocks.
Once you’re done typing an initial match
statement, you can choose
Complete Current Statement (Shift+Ctrl+Enter)
and PyCharm will complete the remaining part, including the colon and the first part
of the case
block. The caret will be left in place for you to start typing
the rest of the case
block.
PyCharm’s built-in formatter recognizes match statements and helps you format them correctly.
In Python 3.10 you will be able to use int | str
for union types instead
of Union[int, str]
. This functionality is already available in earlier
versions of Python through the use of from __future__ import annotations
.
PyCharm provides overall code insight for the new syntax, including intention actions
and information in the Quick Documentation. PyCharm now supports type inference for
isinstance
and issubclass
arguments with the new syntax type.
typing.Literal
in various collection types,
which makes it possible to match against specific values of the collections’
elements. This works even for nested collections.
Working in the Python console is now supported on both the client machine and the host side. During a collaborative coding session, guests can review the code while the host runs it in the interactive console. Support for the Python console in Code With Me comes complete with all the usual PyCharm features, such as on-the-fly syntax highlighting with inspections and code completion.
When you are in Following mode during a Code With Me session, it is possible to keep track of which code completion suggestions the person you are following uses. Also, for any session type, guests’ completion results are exactly the same as they would have been for the host.
Code With Me recently launched two new relay servers: one on the west coast of the US and another one in South Africa. This has made the ping almost three times faster.
In PyCharm 2021.1 we implemented the Python Packages tool window to manage packages for the currently selected Python interpreter. Now you can install packages, not only from the PyPI repository, but also from VCS or a local machine. Click the Add Package link on the Python Packages toolbar and select From Version Control | From Disc.
PyCharm 2021.2 includes a number of helpful updates for coding with screen reader mode enabled on macOS. It will narrate code completion suggestions, the content of the selected combo box and combo box lists, and the results of your queries in Search Everywhere.
Now PyCharm can complete fields, nested fields, and fields inside aggregation expressions, as well as query operators, projection operators, update operators, and aggregation stages in the MongoDB console.
Context live templates now work directly from the data editor. If you’re working with a table and you wish to query it, you can easily do so with the help of the SQL scripts action!
PyCharm lets you preview HTML files in a browser using the built-in web server. Now it is able to automatically update the pages in a browser as you edit and save your HTML, CSS, and JavaScript files. To get started, open an HTML file in the editor, hover over the corner of the editor, and click on the icon for the browser you want to use – all browsers are supported.
You will no longer need to waste time on refactoring useState values and functions one by one – PyCharm can now rename both for you! Place the caret on a state value and press Shift+F6 or go to Refactor | Rename from the right-click context menu.
require()
Did you know that PyCharm can add missing import statements as you complete ES6
symbols? Now it can do the same for CommonJS modules – require
imports will
be inserted on code completion.
Adding new project dependencies to package.json has become even easier, as code completion now works for private npm packages. PyCharm lets you check information about the latest versions of the package, just like it does for public packages.
We’ve expanded the list of possible pre-commit actions with the ability to execute tests. Tick the Run Tests checkbox in the Before Commit section to test the applied changes. You can also customize the Analyze code and Cleanup options by clicking Choose profile next to them. The progress and results of all the pre-commit checks appear in the Commit area.
Connect PyCharm to your organization in JetBrains Space, our new platform for software development and team collaboration, to view and clone project repositories and to review your teammates’ code. To log in to Space, click the Get from VCS button on the Welcome screen, select Space on the left, and enter your organization URL in the dedicated field. Integration with Space is now available out of the box.
It is easy to track a job’s progress by just looking at the commits list, as we’ve introduced icons for Space job statuses in the Log tab of the Git tool window. If you click on an icon, the IDE will open a popup with the automation info for that job.
If you don’t need the status information, click the eye icon above the log and select Show Columns | Space Automation.
Your IDE can now show related branches in the selected code review. You can see the list of branches that contain the commits made while working on the current issue in the Details tab.
Communicating with teammates in Space code reviews is now more convenient, as you
can mention them with @
followed by the colleague’s name. This minor
but helpful feature works in the timeline and in code comments.
Please note that features marked Pro only are supported only in PyCharm Professional Edition.