diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index e05678f..52f3e79 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: ["3.x"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f4677f..7396855 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11"] deps: [test_extra] # Test all on ubuntu, test ends on macos include: @@ -27,15 +27,15 @@ jobs: python-version: "3.8" deps: test_extra - os: macos-latest - python-version: "3.10" + python-version: "3.11" deps: test_extra # Tests minimal dependencies set - os: ubuntu-latest - python-version: "3.10" + python-version: "3.11" deps: test # Tests latest development Python version - os: ubuntu-latest - python-version: "3.11-dev" + python-version: "3.12-dev" deps: test # Installing optional dependencies stuff takes ages on PyPy - os: ubuntu-latest diff --git a/IPython/core/completer.py b/IPython/core/completer.py index f2853d3..f0bbb4e 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -59,7 +59,8 @@ and press :kbd:`Tab` to expand it to its latex form. Both forward and backward completions can be deactivated by setting the -:any:`Completer.backslash_combining_completions` option to ``False``. +:std:configtrait:`Completer.backslash_combining_completions` option to +``False``. Experimental @@ -166,7 +167,7 @@ this can be achieved by adding a list of identifiers of matchers which should not be suppressed to ``MatcherResult`` under ``do_not_suppress`` key. The suppression behaviour can is user-configurable via -:any:`IPCompleter.suppress_competing_matchers`. +:std:configtrait:`IPCompleter.suppress_competing_matchers`. """ @@ -255,7 +256,7 @@ except ImportError: JEDI_INSTALLED = False -if TYPE_CHECKING or GENERATING_DOCUMENTATION: +if TYPE_CHECKING or GENERATING_DOCUMENTATION and sys.version_info >= (3, 11): from typing import cast from typing_extensions import TypedDict, NotRequired, Protocol, TypeAlias, TypeGuard else: @@ -284,7 +285,7 @@ if GENERATING_DOCUMENTATION: # write this). With below range we cover them all, with a density of ~67% # biggest next gap we consider only adds up about 1% density and there are 600 # gaps that would need hard coding. -_UNICODE_RANGES = [(32, 0x3134b), (0xe0001, 0xe01f0)] +_UNICODE_RANGES = [(32, 0x323B0), (0xE0001, 0xE01F0)] # Public API __all__ = ["Completer", "IPCompleter"] @@ -972,7 +973,7 @@ class Completer(Configurable): help="""Activate greedy completion. .. deprecated:: 8.8 - Use :any:`Completer.evaluation` and :any:`Completer.auto_close_dict_keys` instead. + Use :std:configtrait:`Completer.evaluation` and :std:configtrait:`Completer.auto_close_dict_keys` instead. When enabled in IPython 8.8 or newer, changes configuration as follows: diff --git a/IPython/core/release.py b/IPython/core/release.py index e2ce2ea..0416637 100644 --- a/IPython/core/release.py +++ b/IPython/core/release.py @@ -16,7 +16,7 @@ # release. 'dev' as a _version_extra string means this is a development # version _version_major = 8 -_version_minor = 8 +_version_minor = 9 _version_patch = 0 _version_extra = ".dev" # _version_extra = "rc1" diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index 5e8cb35..7783798 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -99,7 +99,7 @@ def test_unicode_range(): assert len_exp == len_test, message # fail if new unicode symbols have been added. - assert len_exp <= 138552, message + assert len_exp <= 143041, message @contextmanager diff --git a/IPython/extensions/tests/test_autoreload.py b/IPython/extensions/tests/test_autoreload.py index d87f6db..89a4add 100644 --- a/IPython/extensions/tests/test_autoreload.py +++ b/IPython/extensions/tests/test_autoreload.py @@ -369,7 +369,8 @@ class TestAutoreload(Fixture): self.shell.run_code("assert func2() == 'changed'") self.shell.run_code("t = Test(); assert t.new_func() == 'changed'") self.shell.run_code("assert number == 1") - self.shell.run_code("assert TestEnum.B.value == 'added'") + if sys.version_info < (3, 12): + self.shell.run_code("assert TestEnum.B.value == 'added'") # ----------- TEST IMPORT FROM MODULE -------------------------- diff --git a/IPython/lib/tests/test_lexers.py b/IPython/lib/tests/test_lexers.py index efa00d6..000b8fe 100644 --- a/IPython/lib/tests/test_lexers.py +++ b/IPython/lib/tests/test_lexers.py @@ -4,11 +4,14 @@ # Distributed under the terms of the Modified BSD License. from unittest import TestCase +from pygments import __version__ as pygments_version from pygments.token import Token from pygments.lexers import BashLexer from .. import lexers +pyg214 = tuple(int(x) for x in pygments_version.split(".")[:2]) >= (2, 14) + class TestLexers(TestCase): """Collection of lexers tests""" @@ -18,25 +21,26 @@ class TestLexers(TestCase): def testIPythonLexer(self): fragment = '!echo $HOME\n' - tokens = [ + bash_tokens = [ (Token.Operator, '!'), ] - tokens.extend(self.bash_lexer.get_tokens(fragment[1:])) - self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + bash_tokens.extend(self.bash_lexer.get_tokens(fragment[1:])) + ipylex_token = list(self.lexer.get_tokens(fragment)) + assert bash_tokens[:-1] == ipylex_token[:-1] - fragment_2 = '!' + fragment + fragment_2 = "!" + fragment tokens_2 = [ (Token.Operator, '!!'), - ] + tokens[1:] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + ] + bash_tokens[1:] + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment_2 = '\t %%!\n' + fragment[1:] tokens_2 = [ (Token.Text, '\t '), (Token.Operator, '%%!'), (Token.Text, '\n'), - ] + tokens[1:] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + ] + bash_tokens[1:] + assert tokens_2 == list(self.lexer.get_tokens(fragment_2)) fragment_2 = 'x = ' + fragment tokens_2 = [ @@ -44,8 +48,8 @@ class TestLexers(TestCase): (Token.Text, ' '), (Token.Operator, '='), (Token.Text, ' '), - ] + tokens - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + ] + bash_tokens + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment_2 = 'x, = ' + fragment tokens_2 = [ @@ -54,8 +58,8 @@ class TestLexers(TestCase): (Token.Text, ' '), (Token.Operator, '='), (Token.Text, ' '), - ] + tokens - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + ] + bash_tokens + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment_2 = 'x, = %sx ' + fragment[1:] tokens_2 = [ @@ -67,8 +71,10 @@ class TestLexers(TestCase): (Token.Operator, '%'), (Token.Keyword, 'sx'), (Token.Text, ' '), - ] + tokens[1:] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + ] + bash_tokens[1:] + if tokens_2[7] == (Token.Text, " ") and pyg214: # pygments 2.14+ + tokens_2[7] = (Token.Text.Whitespace, " ") + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment_2 = 'f = %R function () {}\n' tokens_2 = [ @@ -80,7 +86,7 @@ class TestLexers(TestCase): (Token.Keyword, 'R'), (Token.Text, ' function () {}\n'), ] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + assert tokens_2 == list(self.lexer.get_tokens(fragment_2)) fragment_2 = '\t%%xyz\n$foo\n' tokens_2 = [ @@ -89,7 +95,7 @@ class TestLexers(TestCase): (Token.Keyword, 'xyz'), (Token.Text, '\n$foo\n'), ] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + assert tokens_2 == list(self.lexer.get_tokens(fragment_2)) fragment_2 = '%system?\n' tokens_2 = [ @@ -98,7 +104,7 @@ class TestLexers(TestCase): (Token.Operator, '?'), (Token.Text, '\n'), ] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment_2 = 'x != y\n' tokens_2 = [ @@ -109,7 +115,7 @@ class TestLexers(TestCase): (Token.Name, 'y'), (Token.Text, '\n'), ] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment_2 = ' ?math.sin\n' tokens_2 = [ @@ -118,7 +124,7 @@ class TestLexers(TestCase): (Token.Text, 'math.sin'), (Token.Text, '\n'), ] - self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + assert tokens_2[:-1] == list(self.lexer.get_tokens(fragment_2))[:-1] fragment = ' *int*?\n' tokens = [ @@ -126,7 +132,7 @@ class TestLexers(TestCase): (Token.Operator, '?'), (Token.Text, '\n'), ] - self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + assert tokens == list(self.lexer.get_tokens(fragment)) fragment = '%%writefile -a foo.py\nif a == b:\n pass' tokens = [ @@ -145,7 +151,9 @@ class TestLexers(TestCase): (Token.Keyword, 'pass'), (Token.Text, '\n'), ] - self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + if tokens[10] == (Token.Text, "\n") and pyg214: # pygments 2.14+ + tokens[10] = (Token.Text.Whitespace, "\n") + assert tokens[:-1] == list(self.lexer.get_tokens(fragment))[:-1] fragment = '%%timeit\nmath.sin(0)' tokens = [ @@ -173,4 +181,4 @@ class TestLexers(TestCase): (Token.Punctuation, '>'), (Token.Text, '\n'), ] - self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + assert tokens == list(self.lexer.get_tokens(fragment)) diff --git a/IPython/terminal/shortcuts.py b/IPython/terminal/shortcuts.py index 7d6de8b..6ca91ec 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -68,10 +68,15 @@ def create_ipython_shortcuts(shell): reformat_text_before_cursor(event.current_buffer, event.current_buffer.document, shell) event.current_buffer.validate_and_handle() - kb.add('escape', 'enter', filter=(has_focus(DEFAULT_BUFFER) - & ~has_selection - & insert_mode - ))(reformat_and_execute) + @Condition + def ebivim(): + return shell.emacs_bindings_in_vi_insert_mode + + kb.add( + "escape", + "enter", + filter=(has_focus(DEFAULT_BUFFER) & ~has_selection & insert_mode & ebivim), + )(reformat_and_execute) kb.add("c-\\")(quit) @@ -333,10 +338,6 @@ def create_ipython_shortcuts(shell): if sys.platform == "win32": kb.add("c-v", filter=(has_focus(DEFAULT_BUFFER) & ~vi_mode))(win_paste) - @Condition - def ebivim(): - return shell.emacs_bindings_in_vi_insert_mode - focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode @kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode)) diff --git a/docs/source/whatsnew/version8.rst b/docs/source/whatsnew/version8.rst index d3c3370..e1d4574 100644 --- a/docs/source/whatsnew/version8.rst +++ b/docs/source/whatsnew/version8.rst @@ -2,6 +2,44 @@ 8.x Series ============ +.. _version 8.8.0: + +IPython 8.8.0 +------------- + +First release of IPython in 2023 as there was no release at the end of +December. + +This is an unusually big release (relatively speaking) with more than 15 Pull +Requests merge. + +Of particular interest are: + + - :ghpull:`13852` that replace the greedy completer and improve + completion, in particular for dictionary keys. + - :ghpull:`13858` that adds ``py.typed`` to ``setup.cfg`` to make sure it is + bundled in wheels. + - :ghpull:`13869` that implements tab completions for IPython options in the + shell when using `argcomplete `. I + believe this also needs a recent version of Traitlets. + - :ghpull:`13865` makes the ``inspector`` class of `InteractiveShell` + configurable. + - :ghpull:`13880` that remove minor-version entrypoints as the minor version + entry points that would be included in the wheel would be the one of the + Python version that was used to build the ``whl`` file. + +In no particular order, the rest of the changes update the test suite to be +compatible with Pygments 2.14, various docfixes, testing on more recent python +versions and various updates. + +As usual you can find the full list of PRs on GitHub under `the 8.8 milestone +`__. + +Many thanks to @krassowski for the many PRs and @jasongrout for reviewing and +merging contributions. + +Thanks to the `D. E. Shaw group `__ for sponsoring +work on IPython and related libraries. .. _version 8.7.0: @@ -138,7 +176,7 @@ Here is a non exhaustive list of changes that have been implemented for IPython - Fix paste magic on wayland. :ghpull:`13671` - show maxlen in deque's repr. :ghpull:`13648` -Restore line numbers for Input +Restore line numbers for Input ------------------------------ Line number information in tracebacks from input are restored. @@ -269,7 +307,7 @@ Thanks to the `D. E. Shaw group `__ for sponsoring work on IPython and related libraries. .. _version 8.1.1: - + IPython 8.1.1 ------------- @@ -403,10 +441,10 @@ The 8.x branch started diverging from its predecessor around IPython 7.12 (January 2020). This release contains 250+ pull requests, in addition to many of the features -and backports that have made it to the 7.x branch. Please see the +and backports that have made it to the 7.x branch. Please see the `8.0 milestone `__ for the full list of pull requests. -Please feel free to send pull requests to updates those notes after release, +Please feel free to send pull requests to updates those notes after release, I have likely forgotten a few things reviewing 250+ PRs. Dependencies changes/downstream packaging @@ -421,7 +459,7 @@ looking for help to do so. - minimal Python is now 3.8 - ``nose`` is not a testing requirement anymore - ``pytest`` replaces nose. - - ``iptest``/``iptest3`` cli entrypoints do not exists anymore. + - ``iptest``/``iptest3`` cli entrypoints do not exists anymore. - minimum officially support ``numpy`` version has been bumped, but this should not have much effect on packaging. @@ -443,7 +481,7 @@ deprecation warning: - Please add **since which version** something is deprecated. As a side note, it is much easier to conditionally compare version -numbers rather than using ``try/except`` when functionality changes with a version. +numbers rather than using ``try/except`` when functionality changes with a version. I won't list all the removed features here, but modules like ``IPython.kernel``, which was just a shim module around ``ipykernel`` for the past 8 years, have been @@ -475,7 +513,7 @@ by mypy. Featured changes ---------------- -Here is a features list of changes in IPython 8.0. This is of course non-exhaustive. +Here is a features list of changes in IPython 8.0. This is of course non-exhaustive. Please note as well that many features have been added in the 7.x branch as well (and hence why you want to read the 7.x what's new notes), in particular features contributed by QuantStack (with respect to debugger protocol and Xeus @@ -523,7 +561,7 @@ The error traceback is now correctly formatted, showing the cell number in which ZeroDivisionError: division by zero -The ``stack_data`` package has been integrated, which provides smarter information in the traceback; +The ``stack_data`` package has been integrated, which provides smarter information in the traceback; in particular it will highlight the AST node where an error occurs which can help to quickly narrow down errors. For example in the following snippet:: @@ -563,7 +601,7 @@ and IPython 8.0 is capable of telling you where the index error occurs:: ----> 3 return x[0][i][0] ^^^^^^^ -The corresponding locations marked here with ``^`` will show up highlighted in +The corresponding locations marked here with ``^`` will show up highlighted in the terminal and notebooks. Finally, a colon ``::`` and line number is appended after a filename in @@ -760,7 +798,7 @@ Previously, this was not the case for the Vi-mode prompts:: This is now fixed, and Vi prompt prefixes - ``[ins]`` and ``[nav]`` - are skipped just as the normal ``In`` would be. -IPython shell can be started in the Vi mode using ``ipython --TerminalInteractiveShell.editing_mode=vi``, +IPython shell can be started in the Vi mode using ``ipython --TerminalInteractiveShell.editing_mode=vi``, You should be able to change mode dynamically with ``%config TerminalInteractiveShell.editing_mode='vi'`` Empty History Ranges @@ -787,8 +825,8 @@ when followed with :kbd:`F2`), send it to `dpaste.org `_ using Windows timing implementation: Switch to process_time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Timing on Windows, for example with ``%%time``, was changed from being based on ``time.perf_counter`` -(which counted time even when the process was sleeping) to being based on ``time.process_time`` instead +Timing on Windows, for example with ``%%time``, was changed from being based on ``time.perf_counter`` +(which counted time even when the process was sleeping) to being based on ``time.process_time`` instead (which only counts CPU time). This brings it closer to the behavior on Linux. See :ghpull:`12984`. Miscellaneous @@ -813,7 +851,7 @@ Re-added support for XDG config directories ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XDG support through the years comes and goes. There is a tension between having -an identical location for configuration in all platforms versus having simple instructions. +an identical location for configuration in all platforms versus having simple instructions. After initial failures a couple of years ago, IPython was modified to automatically migrate XDG config files back into ``~/.ipython``. That migration code has now been removed. IPython now checks the XDG locations, so if you _manually_ move your config @@ -841,7 +879,7 @@ Removing support for older Python versions We are removing support for Python up through 3.7, allowing internal code to use the more -efficient ``pathlib`` and to make better use of type annotations. +efficient ``pathlib`` and to make better use of type annotations. .. image:: ../_images/8.0/pathlib_pathlib_everywhere.jpg :alt: "Meme image of Toy Story with Woody and Buzz, with the text 'pathlib, pathlib everywhere'" diff --git a/setupbase.py b/setupbase.py index 748b4dd..a867c73 100644 --- a/setupbase.py +++ b/setupbase.py @@ -211,20 +211,15 @@ def find_entry_points(): use, our own build_scripts_entrypt class below parses these and builds command line scripts. - Each of our entry points gets a plain name, e.g. ipython, a name - suffixed with the Python major version number, e.g. ipython3, and - a name suffixed with the Python major.minor version number, eg. ipython3.8. + Each of our entry points gets a plain name, e.g. ipython, and a name + suffixed with the Python major version number, e.g. ipython3. """ ep = [ 'ipython%s = IPython:start_ipython', ] major_suffix = str(sys.version_info[0]) - minor_suffix = ".".join([str(sys.version_info[0]), str(sys.version_info[1])]) - return ( - [e % "" for e in ep] - + [e % major_suffix for e in ep] - + [e % minor_suffix for e in ep] - ) + return [e % "" for e in ep] + [e % major_suffix for e in ep] + class install_lib_symlink(Command): user_options = [ diff --git a/tools/release_helper.sh b/tools/release_helper.sh index d221f55..ebf8098 100644 --- a/tools/release_helper.sh +++ b/tools/release_helper.sh @@ -2,15 +2,6 @@ # when releasing with bash, simple source it to get asked questions. # misc check before starting - -python -c 'import keyring' -python -c 'import twine' -python -c 'import sphinx' -python -c 'import sphinx_rtd_theme' -python -c 'import pytest' -python -c 'import build' - - BLACK=$(tput setaf 1) RED=$(tput setaf 1) GREEN=$(tput setaf 2) @@ -22,6 +13,22 @@ WHITE=$(tput setaf 7) NOR=$(tput sgr0) +echo "Checking all tools are installed..." + +python -c 'import keyring' +python -c 'import twine' +python -c 'import sphinx' +python -c 'import sphinx_rtd_theme' +python -c 'import pytest' +python -c 'import build' +# those are necessary fo building the docs +echo "Checking imports for docs" +python -c 'import numpy' +python -c 'import matplotlib' + + + + echo "Will use $BLUE'$EDITOR'$NOR to edit files when necessary" echo -n "PREV_RELEASE (X.y.z) [$PREV_RELEASE]: " read input