Draft
Conversation
Carreau
reviewed
Jun 2, 2023
IPython/core/inputtransformer2.py
Outdated
|
|
||
| # only for type checking, do not import this, it lead to a circular | ||
| # import | ||
| if False: |
Member
There was a problem hiding this comment.
You can do
from typing import TYPE_CHECKING
...
if TYPE_CHECKING:
| 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) |
IPython/core/inputtransformer2.py
Outdated
Comment on lines
+244
to
+245
| shell = kwargs.get("shell") | ||
| display = kwargs.get("display", False) |
Member
There was a problem hiding this comment.
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__(...):
Author
There was a problem hiding this comment.
Very good idea, thank you. This solution is a lot less intrusive. Done in 79a23bf.
IPython/core/inputtransformer2.py
Outdated
| ] | ||
| self.line_transforms = [ | ||
| cell_magic, | ||
| autobalance, |
Member
There was a problem hiding this comment.
And here you should be able to have Autobalancer(shell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
%timefor 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.