99import functools
1010import re
1111import tokenize
12+ import warnings
1213from tokenize import untokenize , TokenError
1314from io import StringIO
1415
4243
4344class InputTransformer (metaclass = abc .ABCMeta ):
4445 """Abstract base class for line-based input transformers."""
45-
46+
47+ def __init__ (self ):
48+ warnings .warn (
49+ "`InputTransformer` has been deprecated since IPython 7.0"
50+ " and emit a warnig since IPython 8.31, it"
51+ " will be removed in the future" ,
52+ DeprecationWarning ,
53+ stacklevel = 2 ,
54+ )
55+
4656 @abc .abstractmethod
4757 def push (self , line ):
4858 """Send a line of input to the transformer, returning the transformed
@@ -78,6 +88,14 @@ def transformer_factory(**kwargs):
7888class StatelessInputTransformer (InputTransformer ):
7989 """Wrapper for a stateless input transformer implemented as a function."""
8090 def __init__ (self , func ):
91+ super ().__init__ ()
92+ warnings .warn (
93+ "`StatelessInputTransformer` has been deprecated since IPython 7.0"
94+ " and emit a warnig since IPython 8.31, it"
95+ " will be removed in the future" ,
96+ DeprecationWarning ,
97+ stacklevel = 2 ,
98+ )
8199 self .func = func
82100
83101 def __repr__ (self ):
@@ -96,6 +114,14 @@ class CoroutineInputTransformer(InputTransformer):
96114 """Wrapper for an input transformer implemented as a coroutine."""
97115 def __init__ (self , coro , ** kwargs ):
98116 # Prime it
117+ super ().__init__ ()
118+ warnings .warn (
119+ "`CoroutineInputTransformer` has been deprecated since IPython 7.0"
120+ " and emit a warnig since IPython 8.31, it"
121+ " will be removed in the future" ,
122+ DeprecationWarning ,
123+ stacklevel = 2 ,
124+ )
99125 self .coro = coro (** kwargs )
100126 next (self .coro )
101127
@@ -122,6 +148,13 @@ class TokenInputTransformer(InputTransformer):
122148 return an iterable which can be passed to tokenize.untokenize().
123149 """
124150 def __init__ (self , func ):
151+ warnings .warn (
152+ "`CoroutineInputTransformer` has been deprecated since IPython 7.0"
153+ " and emit a warnig since IPython 8.31, it"
154+ " will be removed in the future" ,
155+ DeprecationWarning ,
156+ stacklevel = 2 ,
157+ )
125158 self .func = func
126159 self .buf = []
127160 self .reset_tokenizer ()
@@ -167,7 +200,7 @@ def reset(self):
167200
168201class assemble_python_lines (TokenInputTransformer ):
169202 def __init__ (self ):
170- super (assemble_python_lines , self ).__init__ (None )
203+ super ().__init__ (None )
171204
172205 def output (self , tokens ):
173206 return self .reset ()
0 commit comments