Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83684a4

Browse files
committed
🐛 Remove ls from list of system commands to warn about
1 parent 6c44d22 commit 83684a4

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

IPython/core/interactiveshell.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,14 +2414,9 @@ def system_raw(self, cmd):
24142414
cmd = self.var_expand(cmd, depth=1)
24152415
# warn if there is an IPython magic alternative.
24162416
main_cmd = cmd.split()[0]
2417-
has_magic_alternatives = ("pip", "conda", "cd", "ls")
2417+
has_magic_alternatives = ("pip", "conda", "cd")
24182418

2419-
# had to check if the command was an alias expanded because of `ls`
2420-
is_alias_expanded = self.alias_manager.is_alias(main_cmd) and (
2421-
self.alias_manager.retrieve_alias(main_cmd).strip() == cmd.strip()
2422-
)
2423-
2424-
if main_cmd in has_magic_alternatives and not is_alias_expanded:
2419+
if main_cmd in has_magic_alternatives:
24252420
warnings.warn(
24262421
(
24272422
"You executed the system command !{0} which may not work "

IPython/core/tests/test_interactiveshell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def test_control_c(self, *mocks):
623623
self.assertEqual(ip.user_ns["_exit_code"], -signal.SIGINT)
624624

625625
def test_magic_warnings(self):
626-
for magic_cmd in ("ls", "pip", "conda", "cd"):
626+
for magic_cmd in ("pip", "conda", "cd"):
627627
with self.assertWarnsRegex(Warning, "You executed the system command"):
628628
ip.system_raw(magic_cmd)
629629

0 commit comments

Comments
 (0)