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

Skip to content

Commit e41930d

Browse files
authored
Merge branch 'main' into latex_rendering_tempdir
2 parents ba4b5b3 + 7f51a03 commit e41930d

16 files changed

Lines changed: 91 additions & 36 deletions

File tree

.github/workflows/mypy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Run MyPy
22

33
on:
44
push:
5-
branches: [ master, 7.x]
5+
branches: [ main, 7.x]
66
pull_request:
7-
branches: [ master, 7.x]
7+
branches: [ main, 7.x]
88

99
jobs:
1010
build:

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ master, 7.x ]
8+
branches: [ main, 7.x ]
99
pull_request:
10-
branches: [ master, 7.x ]
10+
branches: [ main, 7.x ]
1111

1212
jobs:
1313
formatting:

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- master
87
- '*.x'
98
pull_request:
109
# Run weekly on Monday at 1:23 UTC

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ When opening a new Issue, please take the following steps:
3333

3434
1. Search GitHub and/or Google for your issue to avoid duplicate reports.
3535
Keyword searches for your error messages are most helpful.
36-
2. If possible, try updating to master and reproducing your issue,
36+
2. If possible, try updating to main and reproducing your issue,
3737
because we may have already fixed it.
3838
3. Try to include a minimal reproducible test case.
3939
4. Include relevant system information. Start with the output of:
@@ -53,7 +53,7 @@ Some guidelines on contributing to IPython:
5353
Review and discussion can begin well before the work is complete,
5454
and the more discussion the better.
5555
The worst case is that the PR is closed.
56-
* Pull Requests should generally be made against master
56+
* Pull Requests should generally be made against main
5757
* Pull Requests should be tested, if feasible:
5858
- bugfixes should include regression tests.
5959
- new behavior should at least get minimal exercise.

IPython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
3939
See IPython `README.rst` file for more information:
4040
41-
https://github.com/ipython/ipython/blob/master/README.rst
41+
https://github.com/ipython/ipython/blob/main/README.rst
4242
4343
"""
4444
)

IPython/core/completer.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,19 +675,23 @@ def global_matches(self, text):
675675
matches = []
676676
match_append = matches.append
677677
n = len(text)
678-
for lst in [keyword.kwlist,
679-
builtin_mod.__dict__.keys(),
680-
self.namespace.keys(),
681-
self.global_namespace.keys()]:
678+
for lst in [
679+
keyword.kwlist,
680+
builtin_mod.__dict__.keys(),
681+
list(self.namespace.keys()),
682+
list(self.global_namespace.keys()),
683+
]:
682684
for word in lst:
683685
if word[:n] == text and word != "__builtins__":
684686
match_append(word)
685687

686688
snake_case_re = re.compile(r"[^_]+(_[^_]+)+?\Z")
687-
for lst in [self.namespace.keys(),
688-
self.global_namespace.keys()]:
689-
shortened = {"_".join([sub[0] for sub in word.split('_')]) : word
690-
for word in lst if snake_case_re.match(word)}
689+
for lst in [list(self.namespace.keys()), list(self.global_namespace.keys())]:
690+
shortened = {
691+
"_".join([sub[0] for sub in word.split("_")]): word
692+
for word in lst
693+
if snake_case_re.match(word)
694+
}
691695
for word in shortened.keys():
692696
if word[:n] == text and word != "__builtins__":
693697
match_append(shortened[word])

IPython/lib/tests/test_pretty.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,12 @@ def test_pprint_heap_allocated_type():
141141
Test that pprint works for heap allocated types.
142142
"""
143143
module_name = "xxlimited" if sys.version_info < (3, 10) else "xxlimited_35"
144+
expected_output = (
145+
"xxlimited.Null" if sys.version_info < (3, 10, 6) else "xxlimited_35.Null"
146+
)
144147
xxlimited = pytest.importorskip(module_name)
145148
output = pretty.pretty(xxlimited.Null)
146-
assert output == "xxlimited.Null"
149+
assert output == expected_output
147150

148151

149152
def test_pprint_nomod():

IPython/terminal/shortcuts.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ def cursor_in_leading_ws():
3232
return (not before) or before.isspace()
3333

3434

35+
# Needed for to accept autosuggestions in vi insert mode
36+
def _apply_autosuggest(event):
37+
"""
38+
Apply autosuggestion if at end of line.
39+
"""
40+
b = event.current_buffer
41+
d = b.document
42+
after_cursor = d.text[d.cursor_position :]
43+
lines = after_cursor.split("\n")
44+
end_of_current_line = lines[0].strip()
45+
suggestion = b.suggestion
46+
if (suggestion is not None) and (suggestion.text) and (end_of_current_line == ""):
47+
b.insert_text(suggestion.text)
48+
else:
49+
nc.end_of_line(event)
50+
3551
def create_ipython_shortcuts(shell):
3652
"""Set up the prompt_toolkit keyboard shortcuts for IPython"""
3753

@@ -267,15 +283,6 @@ def ebivim():
267283

268284
focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode
269285

270-
# Needed for to accept autosuggestions in vi insert mode
271-
def _apply_autosuggest(event):
272-
b = event.current_buffer
273-
suggestion = b.suggestion
274-
if suggestion is not None and suggestion.text:
275-
b.insert_text(suggestion.text)
276-
else:
277-
nc.end_of_line(event)
278-
279286
@kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode))
280287
def _(event):
281288
_apply_autosuggest(event)

IPython/tests/test_shortcuts.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
from IPython.terminal.shortcuts import _apply_autosuggest
3+
4+
from unittest.mock import Mock
5+
6+
7+
def make_event(text, cursor, suggestion):
8+
event = Mock()
9+
event.current_buffer = Mock()
10+
event.current_buffer.suggestion = Mock()
11+
event.current_buffer.cursor_position = cursor
12+
event.current_buffer.suggestion.text = suggestion
13+
event.current_buffer.document = Mock()
14+
event.current_buffer.document.get_end_of_line_position = Mock(return_value=0)
15+
event.current_buffer.document.text = text
16+
event.current_buffer.document.cursor_position = cursor
17+
return event
18+
19+
20+
@pytest.mark.parametrize(
21+
"text, cursor, suggestion, called",
22+
[
23+
("123456", 6, "123456789", True),
24+
("123456", 3, "123456789", False),
25+
("123456 \n789", 6, "123456789", True),
26+
],
27+
)
28+
def test_autosuggest_at_EOL(text, cursor, suggestion, called):
29+
"""
30+
test that autosuggest is only applied at end of line.
31+
"""
32+
33+
event = make_event(text, cursor, suggestion)
34+
event.current_buffer.insert_text = Mock()
35+
_apply_autosuggest(event)
36+
if called:
37+
event.current_buffer.insert_text.assert_called()
38+
else:
39+
event.current_buffer.insert_text.assert_not_called()
40+
# event.current_buffer.document.get_end_of_line_position.assert_called()

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=master
2-
:target: https://codecov.io/github/ipython/ipython?branch=master
1+
.. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=main
2+
:target: https://codecov.io/github/ipython/ipython?branch=main
33

44
.. image:: https://img.shields.io/pypi/v/IPython.svg
55
:target: https://pypi.python.org/pypi/ipython

0 commit comments

Comments
 (0)