##// END OF EJS Templates
Merge branch 'main' into latex_rendering_tempdir
Pieter Eendebak -
r27727:e41930dc merge
parent child Browse files
Show More
@@ -0,0 +1,40 b''
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()
@@ -2,9 +2,9 b' name: Run MyPy'
2
2
3 on:
3 on:
4 push:
4 push:
5 branches: [ master, 7.x]
5 branches: [ main, 7.x]
6 pull_request:
6 pull_request:
7 branches: [ master, 7.x]
7 branches: [ main, 7.x]
8
8
9 jobs:
9 jobs:
10 build:
10 build:
@@ -5,9 +5,9 b' name: Python package'
5
5
6 on:
6 on:
7 push:
7 push:
8 branches: [ master, 7.x ]
8 branches: [ main, 7.x ]
9 pull_request:
9 pull_request:
10 branches: [ master, 7.x ]
10 branches: [ main, 7.x ]
11
11
12 jobs:
12 jobs:
13 formatting:
13 formatting:
@@ -4,7 +4,6 b' on:'
4 push:
4 push:
5 branches:
5 branches:
6 - main
6 - main
7 - master
8 - '*.x'
7 - '*.x'
9 pull_request:
8 pull_request:
10 # Run weekly on Monday at 1:23 UTC
9 # Run weekly on Monday at 1:23 UTC
@@ -33,7 +33,7 b' When opening a new Issue, please take the following steps:'
33
33
34 1. Search GitHub and/or Google for your issue to avoid duplicate reports.
34 1. Search GitHub and/or Google for your issue to avoid duplicate reports.
35 Keyword searches for your error messages are most helpful.
35 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,
37 because we may have already fixed it.
37 because we may have already fixed it.
38 3. Try to include a minimal reproducible test case.
38 3. Try to include a minimal reproducible test case.
39 4. Include relevant system information. Start with the output of:
39 4. Include relevant system information. Start with the output of:
@@ -53,7 +53,7 b' Some guidelines on contributing to IPython:'
53 Review and discussion can begin well before the work is complete,
53 Review and discussion can begin well before the work is complete,
54 and the more discussion the better.
54 and the more discussion the better.
55 The worst case is that the PR is closed.
55 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
57 * Pull Requests should be tested, if feasible:
57 * Pull Requests should be tested, if feasible:
58 - bugfixes should include regression tests.
58 - bugfixes should include regression tests.
59 - new behavior should at least get minimal exercise.
59 - new behavior should at least get minimal exercise.
@@ -38,7 +38,7 b' Python 3.7 was still supported with the 7.x branch.'
38
38
39 See IPython `README.rst` file for more information:
39 See IPython `README.rst` file for more information:
40
40
41 https://github.com/ipython/ipython/blob/master/README.rst
41 https://github.com/ipython/ipython/blob/main/README.rst
42
42
43 """
43 """
44 )
44 )
@@ -675,19 +675,23 b' class Completer(Configurable):'
675 matches = []
675 matches = []
676 match_append = matches.append
676 match_append = matches.append
677 n = len(text)
677 n = len(text)
678 for lst in [keyword.kwlist,
678 for lst in [
679 builtin_mod.__dict__.keys(),
679 keyword.kwlist,
680 self.namespace.keys(),
680 builtin_mod.__dict__.keys(),
681 self.global_namespace.keys()]:
681 list(self.namespace.keys()),
682 list(self.global_namespace.keys()),
683 ]:
682 for word in lst:
684 for word in lst:
683 if word[:n] == text and word != "__builtins__":
685 if word[:n] == text and word != "__builtins__":
684 match_append(word)
686 match_append(word)
685
687
686 snake_case_re = re.compile(r"[^_]+(_[^_]+)+?\Z")
688 snake_case_re = re.compile(r"[^_]+(_[^_]+)+?\Z")
687 for lst in [self.namespace.keys(),
689 for lst in [list(self.namespace.keys()), list(self.global_namespace.keys())]:
688 self.global_namespace.keys()]:
690 shortened = {
689 shortened = {"_".join([sub[0] for sub in word.split('_')]) : word
691 "_".join([sub[0] for sub in word.split("_")]): word
690 for word in lst if snake_case_re.match(word)}
692 for word in lst
693 if snake_case_re.match(word)
694 }
691 for word in shortened.keys():
695 for word in shortened.keys():
692 if word[:n] == text and word != "__builtins__":
696 if word[:n] == text and word != "__builtins__":
693 match_append(shortened[word])
697 match_append(shortened[word])
@@ -141,9 +141,12 b' def test_pprint_heap_allocated_type():'
141 Test that pprint works for heap allocated types.
141 Test that pprint works for heap allocated types.
142 """
142 """
143 module_name = "xxlimited" if sys.version_info < (3, 10) else "xxlimited_35"
143 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 )
144 xxlimited = pytest.importorskip(module_name)
147 xxlimited = pytest.importorskip(module_name)
145 output = pretty.pretty(xxlimited.Null)
148 output = pretty.pretty(xxlimited.Null)
146 assert output == "xxlimited.Null"
149 assert output == expected_output
147
150
148
151
149 def test_pprint_nomod():
152 def test_pprint_nomod():
@@ -32,6 +32,22 b' def cursor_in_leading_ws():'
32 return (not before) or before.isspace()
32 return (not before) or before.isspace()
33
33
34
34
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
35 def create_ipython_shortcuts(shell):
51 def create_ipython_shortcuts(shell):
36 """Set up the prompt_toolkit keyboard shortcuts for IPython"""
52 """Set up the prompt_toolkit keyboard shortcuts for IPython"""
37
53
@@ -267,15 +283,6 b' def create_ipython_shortcuts(shell):'
267
283
268 focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode
284 focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode
269
285
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
279 @kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode))
286 @kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode))
280 def _(event):
287 def _(event):
281 _apply_autosuggest(event)
288 _apply_autosuggest(event)
@@ -1,5 +1,5 b''
1 .. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=master
1 .. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=main
2 :target: https://codecov.io/github/ipython/ipython?branch=master
2 :target: https://codecov.io/github/ipython/ipython?branch=main
3
3
4 .. image:: https://img.shields.io/pypi/v/IPython.svg
4 .. image:: https://img.shields.io/pypi/v/IPython.svg
5 :target: https://pypi.python.org/pypi/ipython
5 :target: https://pypi.python.org/pypi/ipython
@@ -14,12 +14,12 b' For instructions on how to make a developer install see :ref:`devinstall`.'
14 Backporting Pull requests
14 Backporting Pull requests
15 =========================
15 =========================
16
16
17 All pull requests should usually be made against ``master``, if a Pull Request
17 All pull requests should usually be made against ``main``, if a Pull Request
18 need to be backported to an earlier release; then it should be tagged with the
18 need to be backported to an earlier release; then it should be tagged with the
19 correct ``milestone``.
19 correct ``milestone``.
20
20
21 If you tag a pull request with a milestone **before** merging the pull request,
21 If you tag a pull request with a milestone **before** merging the pull request,
22 and the base ref is ``master``, then our backport bot should automatically create
22 and the base ref is ``main``, then our backport bot should automatically create
23 a corresponding pull-request that backport on the correct branch.
23 a corresponding pull-request that backport on the correct branch.
24
24
25 If you have write access to the IPython repository you can also just mention the
25 If you have write access to the IPython repository you can also just mention the
@@ -78,7 +78,7 b' for the release you are actually making::'
78 PREV_RELEASE=4.2.1
78 PREV_RELEASE=4.2.1
79 MILESTONE=5.0
79 MILESTONE=5.0
80 VERSION=5.0.0
80 VERSION=5.0.0
81 BRANCH=master
81 BRANCH=main
82
82
83 For `reproducibility of builds <https://reproducible-builds.org/specs/source-date-epoch/>`_,
83 For `reproducibility of builds <https://reproducible-builds.org/specs/source-date-epoch/>`_,
84 we recommend setting ``SOURCE_DATE_EPOCH`` prior to running the build; record the used value
84 we recommend setting ``SOURCE_DATE_EPOCH`` prior to running the build; record the used value
@@ -196,7 +196,7 b''
196 "cell_type": "markdown",
196 "cell_type": "markdown",
197 "metadata": {},
197 "metadata": {},
198 "source": [
198 "source": [
199 "The `%gui` magic can be similarly used to control Wx, Tk, glut and pyglet applications, [as can be seen in our examples](https://github.com/ipython/ipython/tree/master/examples/lib)."
199 "The `%gui` magic can be similarly used to control Wx, Tk, glut and pyglet applications, [as can be seen in our examples](https://github.com/ipython/ipython/tree/main/examples/lib)."
200 ]
200 ]
201 },
201 },
202 {
202 {
@@ -48,7 +48,7 b' Python 3.7 was still supported with the 7.x branch.'
48
48
49 See IPython `README.rst` file for more information:
49 See IPython `README.rst` file for more information:
50
50
51 https://github.com/ipython/ipython/blob/master/README.rst
51 https://github.com/ipython/ipython/blob/main/README.rst
52
52
53 Python {py} detected.
53 Python {py} detected.
54 {pip}
54 {pip}
@@ -79,8 +79,8 b' def issues_closed_since(period=timedelta(days=365), project="ipython/ipython", p'
79 filtered = [ i for i in allclosed if _parse_datetime(i['closed_at']) > since ]
79 filtered = [ i for i in allclosed if _parse_datetime(i['closed_at']) > since ]
80 if pulls:
80 if pulls:
81 filtered = [ i for i in filtered if _parse_datetime(i['merged_at']) > since ]
81 filtered = [ i for i in filtered if _parse_datetime(i['merged_at']) > since ]
82 # filter out PRs not against master (backports)
82 # filter out PRs not against main (backports)
83 filtered = [ i for i in filtered if i['base']['ref'] == 'master' ]
83 filtered = [i for i in filtered if i["base"]["ref"] == "main"]
84 else:
84 else:
85 filtered = [ i for i in filtered if not is_pull_request(i) ]
85 filtered = [ i for i in filtered if not is_pull_request(i) ]
86
86
@@ -31,7 +31,7 b' MILESTONE=${input:-$MILESTONE}'
31 echo -n "VERSION (X.y.z) [$VERSION]:"
31 echo -n "VERSION (X.y.z) [$VERSION]:"
32 read input
32 read input
33 VERSION=${input:-$VERSION}
33 VERSION=${input:-$VERSION}
34 echo -n "BRANCH (master|X.y) [$BRANCH]:"
34 echo -n "BRANCH (main|X.y) [$BRANCH]:"
35 read input
35 read input
36 BRANCH=${input:-$BRANCH}
36 BRANCH=${input:-$BRANCH}
37
37
@@ -4,6 +4,8 b' Un-targz and retargz a targz file to ensure reproducible build.'
4 usage:
4 usage:
5
5
6 $ export SOURCE_DATE_EPOCH=$(date +%s)
6 $ export SOURCE_DATE_EPOCH=$(date +%s)
7 # or
8 $ export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)
7 ...
9 ...
8 $ python retar.py <tarfile.gz>
10 $ python retar.py <tarfile.gz>
9
11
General Comments 0
You need to be logged in to leave comments. Login now