diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-02-15 11:42:00 +0300 |
---|---|---|
committer | Innokentii Mokin <innokentii@ydb.tech> | 2024-02-16 18:35:18 +0000 |
commit | 7b5df0095abcb037bd84e4682f90c04b36796e3d (patch) | |
tree | 02de55e9d40978330b14e91aa6275ab8db1c2ba3 /contrib/python/ipython/py3/IPython/core/alias.py | |
parent | 4a82bfdb9b900b928096ffe53670200e94ec8a23 (diff) | |
download | ydb-7b5df0095abcb037bd84e4682f90c04b36796e3d.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/alias.py')
-rw-r--r-- | contrib/python/ipython/py3/IPython/core/alias.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/alias.py b/contrib/python/ipython/py3/IPython/core/alias.py index 2ad990231a..52843b3d77 100644 --- a/contrib/python/ipython/py3/IPython/core/alias.py +++ b/contrib/python/ipython/py3/IPython/core/alias.py @@ -190,22 +190,28 @@ class Alias(object): #----------------------------------------------------------------------------- class AliasManager(Configurable): - - default_aliases = List(default_aliases()).tag(config=True) - user_aliases = List(default_value=[]).tag(config=True) - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) + default_aliases: List = List(default_aliases()).tag(config=True) + user_aliases: List = List(default_value=[]).tag(config=True) + shell = Instance( + "IPython.core.interactiveshell.InteractiveShellABC", allow_none=True + ) def __init__(self, shell=None, **kwargs): super(AliasManager, self).__init__(shell=shell, **kwargs) # For convenient access - self.linemagics = self.shell.magics_manager.magics['line'] - self.init_aliases() + if self.shell is not None: + self.linemagics = self.shell.magics_manager.magics["line"] + self.init_aliases() def init_aliases(self): # Load default & user aliases for name, cmd in self.default_aliases + self.user_aliases: - if cmd.startswith('ls ') and self.shell.colors == 'NoColor': - cmd = cmd.replace(' --color', '') + if ( + cmd.startswith("ls ") + and self.shell is not None + and self.shell.colors == "NoColor" + ): + cmd = cmd.replace(" --color", "") self.soft_define_alias(name, cmd) @property @@ -246,7 +252,7 @@ class AliasManager(Configurable): raise ValueError('%s is not an alias' % name) def clear_aliases(self): - for name, cmd in self.aliases: + for name, _ in self.aliases: self.undefine_alias(name) def retrieve_alias(self, name): |