-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autobalance #14081
base: main
Are you sure you want to change the base?
Autobalance #14081
Conversation
IPython/core/inputtransformer2.py
Outdated
|
||
# only for type checking, do not import this, it lead to a circular | ||
# import | ||
if False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do
from typing import TYPE_CHECKING
...
if TYPE_CHECKING:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 10f3017.
symbols are added in the begin of the expression, and closings symbols | ||
at the end of the line. E.g. `1+2)/2]*(2+3` becomes `[(1+2)/2]*(2+3)`. | ||
""", | ||
).tag(config=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
IPython/core/inputtransformer2.py
Outdated
shell = kwargs.get("shell") | ||
display = kwargs.get("display", False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you are adding kwargs everywhere to get shell and display here, but that will break API of external transforms that don't take a kwargs. So we may wan to have a
class Autobalancer:
def __init__(self, shell):
....
def __call__(...):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good idea, thank you. This solution is a lot less intrusive. Done in 79a23bf.
IPython/core/inputtransformer2.py
Outdated
@@ -579,6 +658,7 @@ def __init__(self): | |||
] | |||
self.line_transforms = [ | |||
cell_magic, | |||
autobalance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here you should be able to have Autobalancer(shell)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuation of last thread. Done in 79a23bf.
This PR adds a mode for automatic opening of brackets, braces and braces.
This follows a strange idea that appeared on Saturday the 13th, following the other strange idea in #14077.
The logic used is as follows:
[{()}]
then the line is modified.
Technical points:
%time
for example).Demo:
This is my first time diving into IPython code (and contributing to it), I may have missed a lot things. I place this PR in draft for two reasons:
Finally, I think it is important to mention the adapted xkcd.