Auto-completing parentheses/brackets in PyCharm vs Rider

There's an autocomplete behavior in Rider that I really like, and I would love to see it in PyCharm. I don't know if the setting just doesn't exist, or if I don't know how to enable it.

In Rider, let's say I want to wrap an existing statement in a Math.Floor function. I put my cursor right before the text I want to wrap, and start typing Math.Floor. Once the code completion popup figures out what I'm typing, I can hit Enter, and it will automatically surround the following text with parentheses as appropriate.

// Before
var x = 1.2;
var y = 2.3;
var z = x + y;

// While typing (right before hitting Enter)
var x = 1.2;
var y = 2.3;
var z = Math.Floorx + y;
// After hitting Enter - notice the parentheses are surrounding the 'x + y' text
var x = 1.2;
var y = 2.3;
var z = Math.Floor(x + y);

 

In PyCharm, I'm looking for a similar setting. A common scenario I have is a type hint for a property that I need to wrap with Optional[ ] . I'm looking for a setting where, as soon as I hit Enter to insert the Optional text, it will automatically surround the existing text in brackets.

# Before
from typing import Optional


class MyClass:
def __init__(self):
self._my_var = 0

@property
def my_var(self) -> int:
return self._my_var
# While typing (right before hitting Enter)
@property
def my_var(self) -> Optionalint:
return self._my_var
# After I hit Enter this is what I want to happen - brackets surround the 'int' text
@property
def my_var(self) -> Optional[int]:
return self._my_var

I've looked over the settings in both IDEs and tried enabling/disabling a bunch of them, but I can't figure out if this is doable. Any advice would be appreciated!

 

I've also uploaded videos of the desired behavior in Rider, and the existing behavior I get in PyCharm.

Upload id: 2022_09_23_rZkVnkcTysTjE4Ueyw1Yd2 (files: pycharm.mp4, rider.mp4)

1

Please sign in to leave a comment.