PyCharm 2021.2 EAP 2: Python Packages Installation From Custom Locations
Starting with this EAP, you can join the program in PyCharm Professional only if you have an active JetBrains account. If you have already logged in with your credentials, you can access the EAP builds automatically. If you have not yet logged in, the IDE will redirect you to account.jetbrains.com where you can enter your login and password or create a new JetBrains account.
Read the blog post for more information.
As usual, our main goal for the EAP is to give you a sense of what to expect in the upcoming PyCharm 2021.2 release. We are hoping to get your active feedback on the overall performance of the PyCharm 2021.2 EAP versions, and in particular, on the feel, look, and performance of the new features we will be highlighting throughout the EAP blog posts.
Important! PyCharm EAP builds are not fully tested and might be unstable.
New syntax for union types
In this release, we added support for PEP 604 “Allow writing union types as X | Y”. This PEP was aimed to tackle the syntax verbosity of the current union type. It added a special operator
type.__or__() that allowed writing
int | str instead of
This functionality is already available in earlier versions of Python with
from __future__ import annotations. Mypy recently added support for this style of annotation in their v0.800 release, so it is a good time to try it out with the newly added PyCharm code assistance.
So what exactly is now supported in PyCharm?
- Overall code insight for new syntax, including intention actions.
- The new syntax is supported in PyCharm Quick Documentation. See quick information by placing the caret at the symbol, and press F1 (View | Quick Documentation).
- Type inference for union types for isinstance and issubclass arguments, using the new syntax.
from __future__ import annotationsis recognized so that you can use the new syntax even with earlier versions of Python. Please note that this import works only for annotations, not on runtime inside isinstance/issubclass.
- Inspection and a quick fix to switch to the old-style syntax in earlier Python versions.
Structural Pattern Matching
In the previous EAP, we announced initial support for structural pattern matching (PEP 634, PEP 635, PEP 636). We are still working on making it fully-fledged. Now, inspections like Unused local symbols and Unreachable code work for pattern matching cases.
For all PEPs and Python versions, visit the dedicated page.
Python Packages Tool Window: install packages from custom locations
In PyCharm 2021.1 we implemented the Python Packages tool window to provide you with the quickest and neatest way to preview and install packages for the currently selected Python interpreter. This window is enabled by default, and you can find it in the lower group of the tool windows. At any time you can open it using the main menu: View | Tool Windows | Python Packages.
You can preview installed packages, update them, install new ones or uninstall them via the Python Packages tool window. Note that all this will be performed for the currently selected Python interpreter. To manage the packages across various Python interpreters go to the Python interpreter settings (Preferences | Settings / Python Interpreter).
With this EAP you are no longer limited to the PyPI repository. You can install packages from VCS or a local machine. Click the Add Package link on the Python Packages toolbar and select From Version Control / From Disc.
For the PyPI repository, we implemented a new sorting order. Now when browsing the PyPI repository, the most downloaded packages are shown first in the list of results. We hope that this will help you to find the packages you need faster.
In this EAP release, we worked through a list of issues related to the debugger. Most of them are bug fixes (see the list at the bottom of the page), but some of them in particular are worth giving a special mention.
Preview Tab now works in Debugger
The preview tab that used to work only for files in the Project view now also works for files that open during debugging.
It helps not to pollute the editor with multiple files that open in separate tabs when you stop at a breakpoint, step through the code, navigate between frames, or use the prev/next frame actions.
If you enable the preview, these files will all appear successively in one tab. You can turn this feature on in Preferences / Settings | Editor | General | Editor Tabs.
“Step into my code” dedicated shortcut
We added a dedicated shortcut for the Step into my code action to the standard keymap. It can be found (and customized) in Keymap settings: Preferences / Settings | Keymap | Main Menu | Run | Debugging Actions.
Python Console: changed behaviour
To enable you to do REPL work in the console while scripts are running in the background, we changed the behavior of the Python Console:
If the Python Console tool window is visible, it will be used for executing line / selection instead of the Debug console. If the Python Console tool window is hidden or not initialized yet, a Debug console will be used.
New Terminal options
We’ve improved our in-built terminal with two new options. First, you can now select the cursor shape. Choose whichever you like best!
Second, we now support Use Option as Meta key, similar to the same-name option in the native Terminal on macOS. This allows the Option (⌥) key on the keyboard to act as a meta modifier that can be used in combination with other keys instead of just as an Escape key. For example, you can now use the following shortcuts:
⌥+F– go to the next word
⌥+B– go back a word
⌥+D– delete the next word
You can tick the checkboxes for these options in Preferences/ Settings | Tools | Terminal.
Pytest: managing the test output
It was a regular occurance to get duplicated error messages in the console when running pytest in PyCharm. In PyCharm 2021.1, we introduced special flags
--no-header --no-summary -q to suppress the extra error messages. In this EAP, we added the option to disable extra flags to enable some specific use cases.
This new option will be useful for those who use special hooks in pytest (for instance,
pytest_terminal_summary) that were suppressed by those new flags.
If you are using one of the popular testing libraries such as Hypothesis and cannot see their feedback on your failing tests and test statistics, when running your test in PyCharm, try disabling
--no-header --no-summary -q by going to Preferences | Settings / Advanced Settings / Python and tick the checkbox “Pytest: don’t add “–no-header –no-summary -q”.
Test Sources Root folder
You can now mark a folder as a Test Sources Root. PyCharm will use it as a working directory to run tests under the test root.
To mark a directory as a test root, open the context menu in the project tree by right-clicking the mouse, find the option Mark Directory as and choose Test Sources Root.
Once it’s configured, the Test Sources Root is marked with the light-green folder icon in your project structure in the Project tool window.
You can learn more about configuration of the project structure in PyCharm in the PyCharm Help.
Support for TypeScript types in JSDoc
PyCharm now properly supports the TypeScript syntax used within JSDoc comments in your .js files. Support for some syntactic constructs, such as union types, has already been available for a while. With this release, we’ve reworked and expanded the existing support, making PyCharm recognize more syntactic constructs. We’ve also fixed a lot of known issues. For example, optional properties in @typedef declarations are now supported.
You can learn about other improvements that are underway by looking at the list of related issues here.
Auto-imports for CommonJS modules
The next improvement in this release is for Node.js users. As you may know, PyCharm adds missing import statements as you complete ES6 symbols. It will now do the same for CommonJS modules – require imports will be inserted on code completion.
Whenever the IDE isn’t sure what syntax should be used in a file, it will show you a popup allowing you to choose between using the ES6 and CommonJS syntax.
Notable bug fixes:
- Testing: Doctest: Arguments with keywords are now passed to DocTestRunner. [PY-47625]
- Debugger: PyCharm recognizes and hits the breakpoints correctly when attached to the Autodesk Maya process. [PY-44778]
- Debugger: Attach to the process functionality is available while PyCharm is indexing the project. [PY-48865]
- Debugger: When attaching the debugger to a process in the Python Console, both command execution and its results are displayed in the Debug Console interactive prompt. [PY-40000]
- Debugger: Debugger in Jupyter Notebook is not disconnected after session interruption in external function. [PY-47721]
- Scientific View: For pandas DataFrame column width is now resized automatically adjusting to the length of the column name. [PY-45634]
- Python Console: pasting text to the current cursor position is available again. [PY-38421]
- Testing: Rerunning failed Django tests containing mixins runs original test cases, not mixin classes/methods. [PY-30788]
Those are the most significant changes we have for week four. You can check out all the fixed and improved issues included in this build in the release notes. Stay tuned for more updates next week! For now, you can test the exciting new features and share your feedback in the comments to this post or report bugs, if any, to our issue tracker.
Ready to join the EAP?
Some ground rules
- EAP builds are free to use and expire 30 days after the build date.
- You can install an EAP build side by side with your stable PyCharm version.
- These builds are not fully tested and can be unstable.
- Your feedback is always welcome. Please use our issue tracker and make sure to mention your build version
How to download
Download this EAP from our website. Alternatively, you can use the JetBrains Toolbox App to stay up to date throughout the entire EAP. If you’re on Ubuntu 16.04 or later, you can use snap to get PyCharm EAP and stay up to date.
The PyCharm team
Subscribe to Blog updates
PyCharm 2023.3.4: AI Assistant’s Efficiency Boosters and a more powerful Django Structure tool window
This year, we are trying out a new approach with our releases, moving away from a quarterly schedule to more regular monthly feature-rich releases. This change is intended to deliver new features more rapidly and streamline the feedback process. Upgrade to PyCharm 2023.3.4 New AI Assistant…
PyCharm 2024.1 EAP 6: In-editor Code Review
Our new EAP build for PyCharm 2024.1 is now available for you to download! This new build is packed with a bunch of updates to the integration with version control systems. You can download the new version from our website, update directly from the IDE or via the free Toolbox App, or use snaps…
PyCharm 2024.1 EAP 5: Model Cards for Hugging Face Models, Updates for the HTTP Client, and More
Packed with numerous new features and enhancements, PyCharm 2024.1 EAP 5 brings extended support for GitHub Actions, updates to the HTTP Client, and much more.