Show More
@@ -1,80 +1,83 | |||
|
1 | 1 | name: Run tests |
|
2 | 2 | |
|
3 | 3 | on: |
|
4 | 4 | push: |
|
5 | 5 | branches: |
|
6 | 6 | - main |
|
7 | 7 | - '*.x' |
|
8 | 8 | pull_request: |
|
9 | 9 | # Run weekly on Monday at 1:23 UTC |
|
10 | 10 | schedule: |
|
11 | 11 | - cron: '23 1 * * 1' |
|
12 | 12 | workflow_dispatch: |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | jobs: |
|
16 | 16 | test: |
|
17 | 17 | runs-on: ${{ matrix.os }} |
|
18 | 18 | strategy: |
|
19 | 19 | fail-fast: false |
|
20 | 20 | matrix: |
|
21 | 21 | os: [ubuntu-latest, windows-latest] |
|
22 | 22 | python-version: ["3.8", "3.9", "3.10"] |
|
23 | 23 | deps: [test_extra] |
|
24 | 24 | # Test all on ubuntu, test ends on macos |
|
25 | 25 | include: |
|
26 | 26 | - os: macos-latest |
|
27 | 27 | python-version: "3.8" |
|
28 | 28 | deps: test_extra |
|
29 | 29 | - os: macos-latest |
|
30 | 30 | python-version: "3.10" |
|
31 | 31 | deps: test_extra |
|
32 | 32 | # Tests minimal dependencies set |
|
33 | 33 | - os: ubuntu-latest |
|
34 | 34 | python-version: "3.10" |
|
35 | 35 | deps: test |
|
36 | 36 | # Tests latest development Python version |
|
37 | 37 | - os: ubuntu-latest |
|
38 | 38 | python-version: "3.11-dev" |
|
39 | 39 | deps: test |
|
40 | 40 | # Installing optional dependencies stuff takes ages on PyPy |
|
41 | 41 | - os: ubuntu-latest |
|
42 | 42 | python-version: "pypy-3.8" |
|
43 | 43 | deps: test |
|
44 | 44 | - os: windows-latest |
|
45 | 45 | python-version: "pypy-3.8" |
|
46 | 46 | deps: test |
|
47 | 47 | - os: macos-latest |
|
48 | 48 | python-version: "pypy-3.8" |
|
49 | 49 | deps: test |
|
50 | 50 | |
|
51 | 51 | steps: |
|
52 | 52 | - uses: actions/checkout@v3 |
|
53 | 53 | - name: Set up Python ${{ matrix.python-version }} |
|
54 | 54 | uses: actions/setup-python@v4 |
|
55 | 55 | with: |
|
56 | 56 | python-version: ${{ matrix.python-version }} |
|
57 | 57 | cache: pip |
|
58 | 58 | - name: Install latex |
|
59 | 59 | if: runner.os == 'Linux' && matrix.deps == 'test_extra' |
|
60 | 60 | run: echo "disable latex for now, issues in mirros" #sudo apt-get -yq -o Acquire::Retries=3 --no-install-suggests --no-install-recommends install texlive dvipng |
|
61 | 61 | - name: Install and update Python dependencies |
|
62 | 62 | run: | |
|
63 | 63 | python -m pip install --upgrade pip setuptools wheel build |
|
64 | 64 | python -m pip install --upgrade -e .[${{ matrix.deps }}] |
|
65 | 65 | python -m pip install --upgrade check-manifest pytest-cov |
|
66 | 66 | - name: Try building with Python build |
|
67 | 67 | if: runner.os != 'Windows' # setup.py does not support sdist on Windows |
|
68 | 68 | run: | |
|
69 | 69 | python -m build |
|
70 | 70 | shasum -a 256 dist/* |
|
71 | 71 | - name: Check manifest |
|
72 | 72 | if: runner.os != 'Windows' # setup.py does not support sdist on Windows |
|
73 | 73 | run: check-manifest |
|
74 | 74 | - name: pytest |
|
75 | 75 | env: |
|
76 | 76 | COLUMNS: 120 |
|
77 | 77 | run: | |
|
78 | 78 | pytest --color=yes -raXxs ${{ startsWith(matrix.python-version, 'pypy') && ' ' || '--cov --cov-report=xml' }} |
|
79 | 79 | - name: Upload coverage to Codecov |
|
80 |
uses: codecov/codecov-action@v |
|
|
80 | uses: codecov/codecov-action@v3 | |
|
81 | with: | |
|
82 | name: Test | |
|
83 | files: /home/runner/work/ipython/ipython/coverage.xml |
@@ -1,90 +1,118 | |||
|
1 | 1 | ## Triaging Issues |
|
2 | 2 | |
|
3 | 3 | On the IPython repository, we strive to trust users and give them responsibility. |
|
4 | 4 | By using one of our bots, any user can close issues or add/remove |
|
5 | 5 | labels by mentioning the bot and asking it to do things on your behalf. |
|
6 | 6 | |
|
7 | 7 | To close an issue (or PR), even if you did not create it, use the following: |
|
8 | 8 | |
|
9 | 9 | > @meeseeksdev close |
|
10 | 10 | |
|
11 | 11 | This command can be in the middle of another comment, but must start on its |
|
12 | 12 | own line. |
|
13 | 13 | |
|
14 | 14 | To add labels to an issue, ask the bot to `tag` with a comma-separated list of |
|
15 | 15 | tags to add: |
|
16 | 16 | |
|
17 | 17 | > @meeseeksdev tag windows, documentation |
|
18 | 18 | |
|
19 | 19 | Only already pre-created tags can be added. So far, the list is limited to: |
|
20 | 20 | `async/await`, `backported`, `help wanted`, `documentation`, `notebook`, |
|
21 | 21 | `tab-completion`, `windows` |
|
22 | 22 | |
|
23 | 23 | To remove a label, use the `untag` command: |
|
24 | 24 | |
|
25 | 25 | > @meeseeksdev untag windows, documentation |
|
26 | 26 | |
|
27 | 27 | We'll be adding additional capabilities for the bot and will share them here |
|
28 | 28 | when they are ready to be used. |
|
29 | 29 | |
|
30 | 30 | ## Opening an Issue |
|
31 | 31 | |
|
32 | 32 | When opening a new Issue, please take the following steps: |
|
33 | 33 | |
|
34 | 34 | 1. Search GitHub and/or Google for your issue to avoid duplicate reports. |
|
35 | 35 | Keyword searches for your error messages are most helpful. |
|
36 | 36 | 2. If possible, try updating to main and reproducing your issue, |
|
37 | 37 | because we may have already fixed it. |
|
38 | 38 | 3. Try to include a minimal reproducible test case. |
|
39 | 39 | 4. Include relevant system information. Start with the output of: |
|
40 | 40 | |
|
41 | 41 | python -c "import IPython; print(IPython.sys_info())" |
|
42 | 42 | |
|
43 | 43 | And include any relevant package versions, depending on the issue, such as |
|
44 | 44 | matplotlib, numpy, Qt, Qt bindings (PyQt/PySide), tornado, web browser, etc. |
|
45 | 45 | |
|
46 | 46 | ## Pull Requests |
|
47 | 47 | |
|
48 | 48 | Some guidelines on contributing to IPython: |
|
49 | 49 | |
|
50 | 50 | * All work is submitted via Pull Requests. |
|
51 | 51 | * Pull Requests can be submitted as soon as there is code worth discussing. |
|
52 | 52 | Pull Requests track the branch, so you can continue to work after the PR is submitted. |
|
53 | 53 | Review and discussion can begin well before the work is complete, |
|
54 | 54 | and the more discussion the better. |
|
55 | 55 | The worst case is that the PR is closed. |
|
56 | 56 | * Pull Requests should generally be made against main |
|
57 | 57 | * Pull Requests should be tested, if feasible: |
|
58 | 58 | - bugfixes should include regression tests. |
|
59 | 59 | - new behavior should at least get minimal exercise. |
|
60 | 60 | * New features and backwards-incompatible changes should be documented by adding |
|
61 | 61 | a new file to the [pr](docs/source/whatsnew/pr) directory, see [the README.md |
|
62 | 62 | there](docs/source/whatsnew/pr/README.md) for details. |
|
63 | 63 | * Don't make 'cleanup' pull requests just to change code style. |
|
64 | 64 | We don't follow any style guide strictly, and we consider formatting changes |
|
65 | 65 | unnecessary noise. |
|
66 | 66 | If you're making functional changes, you can clean up the specific pieces of |
|
67 | 67 | code you're working on. |
|
68 | 68 | |
|
69 | [Travis](http://travis-ci.org/#!/ipython/ipython) does a pretty good job testing | |
|
70 | IPython and Pull Requests, but it may make sense to manually perform tests, | |
|
69 | [GitHub Actions](https://github.com/ipython/ipython/actions/workflows/test.yml) does | |
|
70 | a pretty good job testing IPython and Pull Requests, | |
|
71 | but it may make sense to manually perform tests, | |
|
71 | 72 | particularly for PRs that affect `IPython.parallel` or Windows. |
|
72 | 73 | |
|
73 | 74 | For more detailed information, see our [GitHub Workflow](https://github.com/ipython/ipython/wiki/Dev:-GitHub-workflow). |
|
74 | 75 | |
|
75 | 76 | ## Running Tests |
|
76 | 77 | |
|
77 | 78 | All the tests can be run by using |
|
78 | 79 | ```shell |
|
79 | 80 | pytest |
|
80 | 81 | ``` |
|
81 | 82 | |
|
82 | 83 | All the tests for a single module (for example **test_alias**) can be run by using the fully qualified path to the module. |
|
83 | 84 | ```shell |
|
84 | 85 | pytest IPython/core/tests/test_alias.py |
|
85 | 86 | ``` |
|
86 | 87 | |
|
87 | 88 | Only a single test (for example **test_alias_lifecycle**) within a single file can be run by adding the specific test after a `::` at the end: |
|
88 | 89 | ```shell |
|
89 | 90 | pytest IPython/core/tests/test_alias.py::test_alias_lifecycle |
|
90 | 91 | ``` |
|
92 | ||
|
93 | ## Code style | |
|
94 | ||
|
95 | * Before committing, run `darker -r 60625f241f298b5039cb2debc365db38aa7bb522 <file path>` to apply selective `black` formatting on modified regions using [darker](https://github.com/akaihola/darker). | |
|
96 | * For newly added modules or refactors, please enable static typing analysis with `mypy` for the modified module by adding the file path in [`mypy.yml`](https://github.com/ipython/ipython/blob/main/.github/workflows/mypy.yml) workflow. | |
|
97 | * As described in the pull requests section, please avoid excessive formatting changes; if a formatting-only commit is necessary, consider adding its hash to [`.git-blame-ignore-revs`](https://github.com/ipython/ipython/blob/main/.git-blame-ignore-revs) file. | |
|
98 | ||
|
99 | ## Documentation | |
|
100 | ||
|
101 | Sphinx documentation can be built locally using standard sphinx `make` commands. To build HTML documentation from the root of the project, execute: | |
|
102 | ||
|
103 | ```shell | |
|
104 | pip install -r docs/requirements.txt # only needed once | |
|
105 | make -C docs/ html SPHINXOPTS="-W" | |
|
106 | ``` | |
|
107 | ||
|
108 | To force update of the API documentation, precede the `make` command with: | |
|
109 | ||
|
110 | ```shell | |
|
111 | python3 docs/autogen_api.py | |
|
112 | ``` | |
|
113 | ||
|
114 | Similarly, to force-update the configuration, run: | |
|
115 | ||
|
116 | ```shell | |
|
117 | python3 docs/autogen_config.py | |
|
118 | ``` |
@@ -1,174 +1,174 | |||
|
1 | 1 | .. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=main |
|
2 | 2 | :target: https://codecov.io/github/ipython/ipython?branch=main |
|
3 | 3 | |
|
4 | 4 | .. image:: https://img.shields.io/pypi/v/IPython.svg |
|
5 | 5 | :target: https://pypi.python.org/pypi/ipython |
|
6 | 6 | |
|
7 | 7 | .. image:: https://github.com/ipython/ipython/actions/workflows/test.yml/badge.svg |
|
8 |
:target: https://github.com/ipython/ipython/actions/workflows/test.yml |
|
|
8 | :target: https://github.com/ipython/ipython/actions/workflows/test.yml | |
|
9 | 9 | |
|
10 | 10 | .. image:: https://www.codetriage.com/ipython/ipython/badges/users.svg |
|
11 | 11 | :target: https://www.codetriage.com/ipython/ipython/ |
|
12 | 12 | |
|
13 | 13 | .. image:: https://raster.shields.io/badge/Follows-NEP29-brightgreen.png |
|
14 | 14 | :target: https://numpy.org/neps/nep-0029-deprecation_policy.html |
|
15 | 15 | |
|
16 | 16 | .. image:: https://tidelift.com/badges/package/pypi/ipython?style=flat |
|
17 | 17 | :target: https://tidelift.com/subscription/pkg/pypi-ipython |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | =========================================== |
|
21 | 21 | IPython: Productive Interactive Computing |
|
22 | 22 | =========================================== |
|
23 | 23 | |
|
24 | 24 | Overview |
|
25 | 25 | ======== |
|
26 | 26 | |
|
27 | 27 | Welcome to IPython. Our full documentation is available on `ipython.readthedocs.io |
|
28 | 28 | <https://ipython.readthedocs.io/en/stable/>`_ and contains information on how to install, use, and |
|
29 | 29 | contribute to the project. |
|
30 | 30 | IPython (Interactive Python) is a command shell for interactive computing in multiple programming languages, originally developed for the Python programming language, that offers introspection, rich media, shell syntax, tab completion, and history. |
|
31 | 31 | |
|
32 | 32 | **IPython versions and Python Support** |
|
33 | 33 | |
|
34 | 34 | Starting with IPython 7.10, IPython follows `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ |
|
35 | 35 | |
|
36 | 36 | **IPython 7.17+** requires Python version 3.7 and above. |
|
37 | 37 | |
|
38 | 38 | **IPython 7.10+** requires Python version 3.6 and above. |
|
39 | 39 | |
|
40 | 40 | **IPython 7.0** requires Python version 3.5 and above. |
|
41 | 41 | |
|
42 | 42 | **IPython 6.x** requires Python version 3.3 and above. |
|
43 | 43 | |
|
44 | 44 | **IPython 5.x LTS** is the compatible release for Python 2.7. |
|
45 | 45 | If you require Python 2 support, you **must** use IPython 5.x LTS. Please |
|
46 | 46 | update your project configurations and requirements as necessary. |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | The Notebook, Qt console and a number of other pieces are now parts of *Jupyter*. |
|
50 | 50 | See the `Jupyter installation docs <https://jupyter.readthedocs.io/en/latest/install.html>`__ |
|
51 | 51 | if you want to use these. |
|
52 | 52 | |
|
53 | 53 | Main features of IPython |
|
54 | 54 | ======================== |
|
55 | 55 | Comprehensive object introspection. |
|
56 | 56 | |
|
57 | 57 | Input history, persistent across sessions. |
|
58 | 58 | |
|
59 | 59 | Caching of output results during a session with automatically generated references. |
|
60 | 60 | |
|
61 | 61 | Extensible tab completion, with support by default for completion of python variables and keywords, filenames and function keywords. |
|
62 | 62 | |
|
63 | 63 | Extensible system of βmagicβ commands for controlling the environment and performing many tasks related to IPython or the operating system. |
|
64 | 64 | |
|
65 | 65 | A rich configuration system with easy switching between different setups (simpler than changing $PYTHONSTARTUP environment variables every time). |
|
66 | 66 | |
|
67 | 67 | Session logging and reloading. |
|
68 | 68 | |
|
69 | 69 | Extensible syntax processing for special purpose situations. |
|
70 | 70 | |
|
71 | 71 | Access to the system shell with user-extensible alias system. |
|
72 | 72 | |
|
73 | 73 | Easily embeddable in other Python programs and GUIs. |
|
74 | 74 | |
|
75 | 75 | Integrated access to the pdb debugger and the Python profiler. |
|
76 | 76 | |
|
77 | 77 | |
|
78 | 78 | Development and Instant running |
|
79 | 79 | =============================== |
|
80 | 80 | |
|
81 | 81 | You can find the latest version of the development documentation on `readthedocs |
|
82 | 82 | <https://ipython.readthedocs.io/en/latest/>`_. |
|
83 | 83 | |
|
84 | 84 | You can run IPython from this directory without even installing it system-wide |
|
85 | 85 | by typing at the terminal:: |
|
86 | 86 | |
|
87 | 87 | $ python -m IPython |
|
88 | 88 | |
|
89 | 89 | Or see the `development installation docs |
|
90 | 90 | <https://ipython.readthedocs.io/en/latest/install/install.html#installing-the-development-version>`_ |
|
91 | 91 | for the latest revision on read the docs. |
|
92 | 92 | |
|
93 | 93 | Documentation and installation instructions for older version of IPython can be |
|
94 | 94 | found on the `IPython website <https://ipython.org/documentation.html>`_ |
|
95 | 95 | |
|
96 | 96 | |
|
97 | 97 | |
|
98 | 98 | IPython requires Python version 3 or above |
|
99 | 99 | ========================================== |
|
100 | 100 | |
|
101 | 101 | Starting with version 6.0, IPython does not support Python 2.7, 3.0, 3.1, or |
|
102 | 102 | 3.2. |
|
103 | 103 | |
|
104 | 104 | For a version compatible with Python 2.7, please install the 5.x LTS Long Term |
|
105 | 105 | Support version. |
|
106 | 106 | |
|
107 | 107 | If you are encountering this error message you are likely trying to install or |
|
108 | 108 | use IPython from source. You need to checkout the remote 5.x branch. If you are |
|
109 | 109 | using git the following should work:: |
|
110 | 110 | |
|
111 | 111 | $ git fetch origin |
|
112 | 112 | $ git checkout 5.x |
|
113 | 113 | |
|
114 | 114 | If you encounter this error message with a regular install of IPython, then you |
|
115 | 115 | likely need to update your package manager, for example if you are using `pip` |
|
116 | 116 | check the version of pip with:: |
|
117 | 117 | |
|
118 | 118 | $ pip --version |
|
119 | 119 | |
|
120 | 120 | You will need to update pip to the version 9.0.1 or greater. If you are not using |
|
121 | 121 | pip, please inquiry with the maintainers of the package for your package |
|
122 | 122 | manager. |
|
123 | 123 | |
|
124 | 124 | For more information see one of our blog posts: |
|
125 | 125 | |
|
126 | 126 | https://blog.jupyter.org/release-of-ipython-5-0-8ce60b8d2e8e |
|
127 | 127 | |
|
128 | 128 | As well as the following Pull-Request for discussion: |
|
129 | 129 | |
|
130 | 130 | https://github.com/ipython/ipython/pull/9900 |
|
131 | 131 | |
|
132 | 132 | This error does also occur if you are invoking ``setup.py`` directly βΒ which you |
|
133 | 133 | should not βΒ or are using ``easy_install`` If this is the case, use ``pip |
|
134 | 134 | install .`` instead of ``setup.py install`` , and ``pip install -e .`` instead |
|
135 | 135 | of ``setup.py develop`` If you are depending on IPython as a dependency you may |
|
136 | 136 | also want to have a conditional dependency on IPython depending on the Python |
|
137 | 137 | version:: |
|
138 | 138 | |
|
139 | 139 | install_req = ['ipython'] |
|
140 | 140 | if sys.version_info[0] < 3 and 'bdist_wheel' not in sys.argv: |
|
141 | 141 | install_req.remove('ipython') |
|
142 | 142 | install_req.append('ipython<6') |
|
143 | 143 | |
|
144 | 144 | setup( |
|
145 | 145 | ... |
|
146 | 146 | install_requires=install_req |
|
147 | 147 | ) |
|
148 | 148 | |
|
149 | 149 | Alternatives to IPython |
|
150 | 150 | ======================= |
|
151 | 151 | |
|
152 | 152 | IPython may not be to your taste; if that's the case there might be similar |
|
153 | 153 | project that you might want to use: |
|
154 | 154 | |
|
155 | 155 | - The classic Python REPL. |
|
156 | 156 | - `bpython <https://bpython-interpreter.org/>`_ |
|
157 | 157 | - `mypython <https://www.asmeurer.com/mypython/>`_ |
|
158 | 158 | - `ptpython and ptipython <https://pypi.org/project/ptpython/>`_ |
|
159 | 159 | - `Xonsh <https://xon.sh/>`_ |
|
160 | 160 | |
|
161 | 161 | Ignoring commits with git blame.ignoreRevsFile |
|
162 | 162 | ============================================== |
|
163 | 163 | |
|
164 | 164 | As of git 2.23, it is possible to make formatting changes without breaking |
|
165 | 165 | ``git blame``. See the `git documentation |
|
166 | 166 | <https://git-scm.com/docs/git-config#Documentation/git-config.txt-blameignoreRevsFile>`_ |
|
167 | 167 | for more details. |
|
168 | 168 | |
|
169 | 169 | To use this feature you must: |
|
170 | 170 | |
|
171 | 171 | - Install git >= 2.23 |
|
172 | 172 | - Configure your local git repo by running: |
|
173 | 173 | - POSIX: ``tools\configure-git-blame-ignore-revs.sh`` |
|
174 | 174 | - Windows: ``tools\configure-git-blame-ignore-revs.bat`` |
@@ -1,173 +1,172 | |||
|
1 | 1 | .. _integrating: |
|
2 | 2 | |
|
3 | 3 | ===================================== |
|
4 | 4 | Integrating your objects with IPython |
|
5 | 5 | ===================================== |
|
6 | 6 | |
|
7 | 7 | Tab completion |
|
8 | 8 | ============== |
|
9 | 9 | |
|
10 | 10 | To change the attributes displayed by tab-completing your object, define a |
|
11 | 11 | ``__dir__(self)`` method for it. For more details, see the documentation of the |
|
12 | 12 | built-in `dir() function <http://docs.python.org/library/functions.html#dir>`_. |
|
13 | 13 | |
|
14 | 14 | You can also customise key completions for your objects, e.g. pressing tab after |
|
15 | 15 | ``obj["a``. To do so, define a method ``_ipython_key_completions_()``, which |
|
16 | 16 | returns a list of objects which are possible keys in a subscript expression |
|
17 | 17 | ``obj[key]``. |
|
18 | 18 | |
|
19 | 19 | .. versionadded:: 5.0 |
|
20 | 20 | Custom key completions |
|
21 | 21 | |
|
22 | 22 | .. _integrating_rich_display: |
|
23 | 23 | |
|
24 | 24 | Rich display |
|
25 | 25 | ============ |
|
26 | 26 | |
|
27 | 27 | Custom methods |
|
28 | 28 | ---------------------- |
|
29 | 29 | IPython can display richer representations of objects. |
|
30 | 30 | To do this, you can define ``_ipython_display_()``, or any of a number of |
|
31 | 31 | ``_repr_*_()`` methods. |
|
32 | 32 | Note that these are surrounded by single, not double underscores. |
|
33 | 33 | |
|
34 | 34 | .. list-table:: Supported ``_repr_*_`` methods |
|
35 | 35 | :widths: 20 15 15 15 |
|
36 | 36 | :header-rows: 1 |
|
37 | 37 | |
|
38 | 38 | * - Format |
|
39 | 39 | - REPL |
|
40 | 40 | - Notebook |
|
41 | 41 | - Qt Console |
|
42 | 42 | * - ``_repr_pretty_`` |
|
43 | 43 | - yes |
|
44 | 44 | - yes |
|
45 | 45 | - yes |
|
46 | 46 | * - ``_repr_svg_`` |
|
47 | 47 | - no |
|
48 | 48 | - yes |
|
49 | 49 | - yes |
|
50 | 50 | * - ``_repr_png_`` |
|
51 | 51 | - no |
|
52 | 52 | - yes |
|
53 | 53 | - yes |
|
54 | 54 | * - ``_repr_jpeg_`` |
|
55 | 55 | - no |
|
56 | 56 | - yes |
|
57 | 57 | - yes |
|
58 | 58 | * - ``_repr_html_`` |
|
59 | 59 | - no |
|
60 | 60 | - yes |
|
61 | 61 | - no |
|
62 | 62 | * - ``_repr_javascript_`` |
|
63 | 63 | - no |
|
64 | 64 | - yes |
|
65 | 65 | - no |
|
66 | 66 | * - ``_repr_markdown_`` |
|
67 | 67 | - no |
|
68 | 68 | - yes |
|
69 | 69 | - no |
|
70 | 70 | * - ``_repr_latex_`` |
|
71 | 71 | - no |
|
72 | 72 | - yes |
|
73 | 73 | - no |
|
74 | 74 | * - ``_repr_mimebundle_`` |
|
75 | 75 | - no |
|
76 | 76 | - ? |
|
77 | 77 | - ? |
|
78 | 78 | |
|
79 | 79 | If the methods don't exist, or return ``None``, the standard ``repr()`` is used. |
|
80 | 80 | |
|
81 | 81 | For example:: |
|
82 | 82 | |
|
83 | 83 | class Shout(object): |
|
84 | 84 | def __init__(self, text): |
|
85 | 85 | self.text = text |
|
86 | 86 | |
|
87 | 87 | def _repr_html_(self): |
|
88 | 88 | return "<h1>" + self.text + "</h1>" |
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | Special methods |
|
92 | 92 | ^^^^^^^^^^^^^^^ |
|
93 | 93 | |
|
94 | 94 | Pretty printing |
|
95 | 95 | """"""""""""""" |
|
96 | 96 | |
|
97 | 97 | To customize how your object is pretty-printed, add a ``_repr_pretty_`` method |
|
98 | 98 | to the class. |
|
99 | 99 | The method should accept a pretty printer, and a boolean that indicates whether |
|
100 | 100 | the printer detected a cycle. |
|
101 | 101 | The method should act on the printer to produce your customized pretty output. |
|
102 | 102 | Here is an example:: |
|
103 | 103 | |
|
104 | 104 | class MyObject(object): |
|
105 | 105 | |
|
106 | 106 | def _repr_pretty_(self, p, cycle): |
|
107 | 107 | if cycle: |
|
108 | 108 | p.text('MyObject(...)') |
|
109 | 109 | else: |
|
110 | 110 | p.text('MyObject[...]') |
|
111 | 111 | |
|
112 | 112 | For details on how to use the pretty printer, see :py:mod:`IPython.lib.pretty`. |
|
113 | 113 | |
|
114 | 114 | More powerful methods |
|
115 | 115 | """"""""""""""""""""" |
|
116 | 116 | |
|
117 | 117 | .. class:: MyObject |
|
118 | 118 | |
|
119 | 119 | .. method:: _repr_mimebundle_(include=None, exclude=None) |
|
120 | 120 | |
|
121 | 121 | Should return a dictionary of multiple formats, keyed by mimetype, or a tuple |
|
122 | 122 | of two dictionaries: *data, metadata* (see :ref:`Metadata`). |
|
123 | 123 | If this returns something, other ``_repr_*_`` methods are ignored. |
|
124 | 124 | The method should take keyword arguments ``include`` and ``exclude``, though |
|
125 | 125 | it is not required to respect them. |
|
126 | 126 | |
|
127 | 127 | .. method:: _ipython_display_() |
|
128 | 128 | |
|
129 | 129 | Displays the object as a side effect; the return value is ignored. If this |
|
130 | 130 | is defined, all other display methods are ignored. |
|
131 | This method is ignored in the REPL. | |
|
132 | 131 | |
|
133 | 132 | |
|
134 | 133 | Metadata |
|
135 | 134 | ^^^^^^^^ |
|
136 | 135 | |
|
137 | 136 | We often want to provide frontends with guidance on how to display the data. To |
|
138 | 137 | support this, ``_repr_*_()`` methods (except ``_repr_pretty_``?) can also return a ``(data, metadata)`` |
|
139 | 138 | tuple where ``metadata`` is a dictionary containing arbitrary key-value pairs for |
|
140 | 139 | the frontend to interpret. An example use case is ``_repr_jpeg_()``, which can |
|
141 | 140 | be set to return a jpeg image and a ``{'height': 400, 'width': 600}`` dictionary |
|
142 | 141 | to inform the frontend how to size the image. |
|
143 | 142 | |
|
144 | 143 | |
|
145 | 144 | |
|
146 | 145 | Formatters for third-party types |
|
147 | 146 | -------------------------------- |
|
148 | 147 | |
|
149 | 148 | The user can also register formatters for types without modifying the class:: |
|
150 | 149 | |
|
151 | 150 | from bar.baz import Foo |
|
152 | 151 | |
|
153 | 152 | def foo_html(obj): |
|
154 | 153 | return '<marquee>Foo object %s</marquee>' % obj.name |
|
155 | 154 | |
|
156 | 155 | html_formatter = get_ipython().display_formatter.formatters['text/html'] |
|
157 | 156 | html_formatter.for_type(Foo, foo_html) |
|
158 | 157 | |
|
159 | 158 | # Or register a type without importing it - this does the same as above: |
|
160 | 159 | html_formatter.for_type_by_name('bar.baz', 'Foo', foo_html) |
|
161 | 160 | |
|
162 | 161 | Custom exception tracebacks |
|
163 | 162 | =========================== |
|
164 | 163 | |
|
165 | 164 | Rarely, you might want to display a custom traceback when reporting an |
|
166 | 165 | exception. To do this, define the custom traceback using |
|
167 | 166 | `_render_traceback_(self)` method which returns a list of strings, one string |
|
168 | 167 | for each line of the traceback. For example, the `ipyparallel |
|
169 | 168 | <https://ipyparallel.readthedocs.io/>`__ a parallel computing framework for |
|
170 | 169 | IPython, does this to display errors from multiple engines. |
|
171 | 170 | |
|
172 | 171 | Please be conservative in using this feature; by replacing the default traceback |
|
173 | 172 | you may hide important information from the user. |
@@ -1,48 +1,40 | |||
|
1 | 1 | [pytest] |
|
2 | 2 | addopts = --durations=10 |
|
3 | 3 | -p IPython.testing.plugin.pytest_ipdoctest --ipdoctest-modules |
|
4 | 4 | --ignore=docs |
|
5 | 5 | --ignore=examples |
|
6 | 6 | --ignore=htmlcov |
|
7 | 7 | --ignore=ipython_kernel |
|
8 | 8 | --ignore=ipython_parallel |
|
9 | 9 | --ignore=results |
|
10 | 10 | --ignore=tmp |
|
11 | 11 | --ignore=tools |
|
12 | 12 | --ignore=traitlets |
|
13 | 13 | --ignore=IPython/core/tests/daft_extension |
|
14 | 14 | --ignore=IPython/sphinxext |
|
15 | 15 | --ignore=IPython/terminal/pt_inputhooks |
|
16 | 16 | --ignore=IPython/__main__.py |
|
17 | --ignore=IPython/config.py | |
|
18 | --ignore=IPython/frontend.py | |
|
19 | --ignore=IPython/html.py | |
|
20 | --ignore=IPython/nbconvert.py | |
|
21 | --ignore=IPython/nbformat.py | |
|
22 | --ignore=IPython/parallel.py | |
|
23 | --ignore=IPython/qt.py | |
|
24 | 17 | --ignore=IPython/external/qt_for_kernel.py |
|
25 | 18 | --ignore=IPython/html/widgets/widget_link.py |
|
26 | 19 | --ignore=IPython/html/widgets/widget_output.py |
|
27 | 20 | --ignore=IPython/terminal/console.py |
|
28 | --ignore=IPython/terminal/ptshell.py | |
|
29 | 21 | --ignore=IPython/utils/_process_cli.py |
|
30 | 22 | --ignore=IPython/utils/_process_posix.py |
|
31 | 23 | --ignore=IPython/utils/_process_win32.py |
|
32 | 24 | --ignore=IPython/utils/_process_win32_controller.py |
|
33 | 25 | --ignore=IPython/utils/daemonize.py |
|
34 | 26 | --ignore=IPython/utils/eventful.py |
|
35 | 27 | |
|
36 | 28 | --ignore=IPython/kernel |
|
37 | 29 | --ignore=IPython/consoleapp.py |
|
38 | 30 | --ignore=IPython/core/inputsplitter.py |
|
39 | 31 | --ignore=IPython/lib/kernel.py |
|
40 | 32 | --ignore=IPython/utils/jsonutil.py |
|
41 | 33 | --ignore=IPython/utils/localinterfaces.py |
|
42 | 34 | --ignore=IPython/utils/log.py |
|
43 | 35 | --ignore=IPython/utils/signatures.py |
|
44 | 36 | --ignore=IPython/utils/traitlets.py |
|
45 | 37 | --ignore=IPython/utils/version.py |
|
46 | 38 | doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS |
|
47 | 39 | ipdoctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS |
|
48 | 40 | asyncio_mode = strict |
@@ -1,251 +1,252 | |||
|
1 | 1 | # Simple tool to help for release |
|
2 | 2 | # when releasing with bash, simple source it to get asked questions. |
|
3 | 3 | |
|
4 | 4 | # misc check before starting |
|
5 | 5 | |
|
6 | 6 | python -c 'import keyring' |
|
7 | 7 | python -c 'import twine' |
|
8 | 8 | python -c 'import sphinx' |
|
9 | 9 | python -c 'import sphinx_rtd_theme' |
|
10 | 10 | python -c 'import pytest' |
|
11 | python -c 'import build' | |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | BLACK=$(tput setaf 1) |
|
14 | 15 | RED=$(tput setaf 1) |
|
15 | 16 | GREEN=$(tput setaf 2) |
|
16 | 17 | YELLOW=$(tput setaf 3) |
|
17 | 18 | BLUE=$(tput setaf 4) |
|
18 | 19 | MAGENTA=$(tput setaf 5) |
|
19 | 20 | CYAN=$(tput setaf 6) |
|
20 | 21 | WHITE=$(tput setaf 7) |
|
21 | 22 | NOR=$(tput sgr0) |
|
22 | 23 | |
|
23 | 24 | |
|
24 | 25 | echo "Will use $BLUE'$EDITOR'$NOR to edit files when necessary" |
|
25 | 26 | echo -n "PREV_RELEASE (X.y.z) [$PREV_RELEASE]: " |
|
26 | 27 | read input |
|
27 | 28 | PREV_RELEASE=${input:-$PREV_RELEASE} |
|
28 | 29 | echo -n "MILESTONE (X.y) [$MILESTONE]: " |
|
29 | 30 | read input |
|
30 | 31 | MILESTONE=${input:-$MILESTONE} |
|
31 | 32 | echo -n "VERSION (X.y.z) [$VERSION]:" |
|
32 | 33 | read input |
|
33 | 34 | VERSION=${input:-$VERSION} |
|
34 | 35 | echo -n "BRANCH (main|X.y) [$BRANCH]:" |
|
35 | 36 | read input |
|
36 | 37 | BRANCH=${input:-$BRANCH} |
|
37 | 38 | |
|
38 | 39 | ask_section(){ |
|
39 | 40 | echo |
|
40 | 41 | echo $BLUE"$1"$NOR |
|
41 | 42 | echo -n $GREEN"Press Enter to continue, S to skip: "$NOR |
|
42 | 43 | if [ "$ZSH_NAME" = "zsh" ] ; then |
|
43 | 44 | read -k1 value |
|
44 | 45 | value=${value%$'\n'} |
|
45 | 46 | else |
|
46 | 47 | read -n1 value |
|
47 | 48 | fi |
|
48 | 49 | if [ -z "$value" ] || [ $value = 'y' ]; then |
|
49 | 50 | return 0 |
|
50 | 51 | fi |
|
51 | 52 | return 1 |
|
52 | 53 | } |
|
53 | 54 | |
|
54 | 55 | |
|
55 | 56 | maybe_edit(){ |
|
56 | 57 | echo |
|
57 | 58 | echo $BLUE"$1"$NOR |
|
58 | 59 | echo -n $GREEN"Press ${BLUE}e$GREEN to Edit ${BLUE}$1$GREEN, any other keys to skip: "$NOR |
|
59 | 60 | if [ "$ZSH_NAME" = "zsh" ] ; then |
|
60 | 61 | read -k1 value |
|
61 | 62 | value=${value%$'\n'} |
|
62 | 63 | else |
|
63 | 64 | read -n1 value |
|
64 | 65 | fi |
|
65 | 66 | |
|
66 | 67 | echo |
|
67 | 68 | if [ $value = 'e' ] ; then |
|
68 | 69 | $=EDITOR $1 |
|
69 | 70 | fi |
|
70 | 71 | } |
|
71 | 72 | |
|
72 | 73 | |
|
73 | 74 | |
|
74 | 75 | echo |
|
75 | 76 | if ask_section "Updating what's new with information from docs/source/whatsnew/pr" |
|
76 | 77 | then |
|
77 | 78 | python tools/update_whatsnew.py |
|
78 | 79 | |
|
79 | 80 | echo |
|
80 | 81 | echo $BLUE"please move the contents of "docs/source/whatsnew/development.rst" to version-X.rst"$NOR |
|
81 | 82 | echo $GREEN"Press enter to continue"$NOR |
|
82 | 83 | read |
|
83 | 84 | fi |
|
84 | 85 | |
|
85 | 86 | if ask_section "Gen Stats, and authors" |
|
86 | 87 | then |
|
87 | 88 | |
|
88 | 89 | echo |
|
89 | 90 | echo $BLUE"here are all the authors that contributed to this release:"$NOR |
|
90 | 91 | git log --format="%aN <%aE>" $PREV_RELEASE... | sort -u -f |
|
91 | 92 | |
|
92 | 93 | echo |
|
93 | 94 | echo $BLUE"If you see any duplicates cancel (Ctrl-C), then edit .mailmap." |
|
94 | 95 | echo $GREEN"Press enter to continue:"$NOR |
|
95 | 96 | read |
|
96 | 97 | |
|
97 | 98 | echo $BLUE"generating stats"$NOR |
|
98 | 99 | python tools/github_stats.py --milestone $MILESTONE > stats.rst |
|
99 | 100 | |
|
100 | 101 | echo $BLUE"stats.rst files generated."$NOR |
|
101 | 102 | echo $GREEN"Please merge it with the right file (github-stats-X.rst) and commit."$NOR |
|
102 | 103 | echo $GREEN"press enter to continue."$NOR |
|
103 | 104 | read |
|
104 | 105 | |
|
105 | 106 | fi |
|
106 | 107 | |
|
107 | 108 | if ask_section "Generate API difference (using frapuccino)" |
|
108 | 109 | then |
|
109 | 110 | echo $BLUE"Checking out $PREV_RELEASE"$NOR |
|
110 | 111 | git checkout $PREV_RELEASE |
|
111 | 112 | sleep 1 |
|
112 | 113 | echo $BLUE"Saving API to file $PREV_RELEASE"$NOR |
|
113 | 114 | frappuccino IPython IPython.kernel IPython.lib IPython.qt IPython.lib.kernel IPython.html IPython.frontend IPython.external --save IPython-$PREV_RELEASE.json |
|
114 | 115 | echo $BLUE"coming back to $BRANCH"$NOR |
|
115 | 116 | git checkout $BRANCH |
|
116 | 117 | sleep 1 |
|
117 | 118 | echo $BLUE"comparing ..."$NOR |
|
118 | 119 | frappuccino IPython IPython.kernel IPython.lib --compare IPython-$PREV_RELEASE.json |
|
119 | 120 | echo $GREEN"Use the above guideline to write an API changelog ..."$NOR |
|
120 | 121 | echo $GREEN"Press any keys to continue"$NOR |
|
121 | 122 | read |
|
122 | 123 | fi |
|
123 | 124 | |
|
124 | 125 | echo "Cleaning repository" |
|
125 | 126 | git clean -xfdi |
|
126 | 127 | |
|
127 | 128 | echo $GREEN"please update version number in ${RED}IPython/core/release.py${NOR} , Do not commit yet βΒ we'll do it later."$NOR |
|
128 | 129 | echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py${NOR}" |
|
129 | 130 | sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py |
|
130 | 131 | rm IPython/core/release.pybkp |
|
131 | 132 | git diff | cat |
|
132 | 133 | maybe_edit IPython/core/release.py |
|
133 | 134 | |
|
134 | 135 | echo $GREEN"Press enter to continue"$NOR |
|
135 | 136 | read |
|
136 | 137 | |
|
137 | 138 | if ask_section "Build the documentation ?" |
|
138 | 139 | then |
|
139 | 140 | make html -C docs |
|
140 | 141 | echo |
|
141 | 142 | echo $GREEN"Check the docs, press enter to continue"$NOR |
|
142 | 143 | read |
|
143 | 144 | |
|
144 | 145 | fi |
|
145 | 146 | |
|
146 | 147 | if ask_section "Should we commit, tag, push... etc ? " |
|
147 | 148 | then |
|
148 | 149 | echo |
|
149 | 150 | echo $BLUE"Let's commit : git commit -am \"release $VERSION\" -S" |
|
150 | 151 | echo $GREEN"Press enter to commit"$NOR |
|
151 | 152 | read |
|
152 | 153 | git commit -am "release $VERSION" -S |
|
153 | 154 | |
|
154 | 155 | echo |
|
155 | 156 | echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR |
|
156 | 157 | echo $GREEN"Make sure you can push"$NOR |
|
157 | 158 | echo $GREEN"Press enter to continue"$NOR |
|
158 | 159 | read |
|
159 | 160 | git push origin $BRANCH |
|
160 | 161 | |
|
161 | 162 | echo |
|
162 | 163 | echo "Let's tag : git tag -am \"release $VERSION\" \"$VERSION\" -s" |
|
163 | 164 | echo $GREEN"Press enter to tag commit"$NOR |
|
164 | 165 | read |
|
165 | 166 | git tag -am "release $VERSION" "$VERSION" -s |
|
166 | 167 | |
|
167 | 168 | echo |
|
168 | 169 | echo $BLUE"And push the tag: git push origin \$VERSION ?"$NOR |
|
169 | 170 | echo $GREEN"Press enter to continue"$NOR |
|
170 | 171 | read |
|
171 | 172 | git push origin $VERSION |
|
172 | 173 | |
|
173 | 174 | |
|
174 | 175 | echo $GREEN"please update version number and back to .dev in ${RED}IPython/core/release.py" |
|
175 | 176 | echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py${NOR}" |
|
176 | 177 | sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py |
|
177 | 178 | rm IPython/core/release.pybkp |
|
178 | 179 | git diff | cat |
|
179 | 180 | echo $GREEN"Please bump ${RED}the minor version number${NOR}" |
|
180 | 181 | maybe_edit IPython/core/release.py |
|
181 | 182 | echo ${BLUE}"Do not commit yet βΒ we'll do it later."$NOR |
|
182 | 183 | |
|
183 | 184 | |
|
184 | 185 | echo $GREEN"Press enter to continue"$NOR |
|
185 | 186 | read |
|
186 | 187 | |
|
187 | 188 | echo |
|
188 | 189 | echo "Let's commit : "$BLUE"git commit -am \"back to dev\""$NOR |
|
189 | 190 | echo $GREEN"Press enter to commit"$NOR |
|
190 | 191 | read |
|
191 | 192 | git commit -am "back to dev" |
|
192 | 193 | |
|
193 | 194 | echo |
|
194 | 195 | echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR |
|
195 | 196 | echo $GREEN"Press enter to continue"$NOR |
|
196 | 197 | read |
|
197 | 198 | git push origin $BRANCH |
|
198 | 199 | |
|
199 | 200 | |
|
200 | 201 | echo |
|
201 | 202 | echo $BLUE"let's : git checkout $VERSION"$NOR |
|
202 | 203 | echo $GREEN"Press enter to continue"$NOR |
|
203 | 204 | read |
|
204 | 205 | git checkout $VERSION |
|
205 | 206 | fi |
|
206 | 207 | |
|
207 | 208 | if ask_section "Should we build and release ?" |
|
208 | 209 | then |
|
209 | 210 | |
|
210 | 211 | echo $BLUE"going to set SOURCE_DATE_EPOCH"$NOR |
|
211 | 212 | echo $BLUE'export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)'$NOR |
|
212 | 213 | echo $GREEN"Press enter to continue"$NOR |
|
213 | 214 | read |
|
214 | 215 | |
|
215 | 216 | export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) |
|
216 | 217 | |
|
217 | 218 | echo $BLUE"SOURCE_DATE_EPOCH set to $SOURCE_DATE_EPOCH"$NOR |
|
218 | 219 | echo $GREEN"Press enter to continue"$NOR |
|
219 | 220 | read |
|
220 | 221 | |
|
221 | 222 | |
|
222 | 223 | |
|
223 | 224 | echo |
|
224 | 225 | echo $BLUE"Attempting to build package..."$NOR |
|
225 | 226 | |
|
226 | 227 | tools/release |
|
227 | 228 | |
|
228 | 229 | |
|
229 | 230 | echo $RED'$ shasum -a 256 dist/*' |
|
230 | 231 | shasum -a 256 dist/* |
|
231 | 232 | echo $NOR |
|
232 | 233 | |
|
233 | 234 | echo $BLUE"We are going to rebuild, node the hash above, and compare them to the rebuild"$NOR |
|
234 | 235 | echo $GREEN"Press enter to continue"$NOR |
|
235 | 236 | read |
|
236 | 237 | |
|
237 | 238 | echo |
|
238 | 239 | echo $BLUE"Attempting to build package..."$NOR |
|
239 | 240 | |
|
240 | 241 | tools/release |
|
241 | 242 | |
|
242 | 243 | echo $RED"Check the shasum for SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" |
|
243 | 244 | echo $RED'$ shasum -a 256 dist/*' |
|
244 | 245 | shasum -a 256 dist/* |
|
245 | 246 | echo $NOR |
|
246 | 247 | |
|
247 | 248 | if ask_section "upload packages ?" |
|
248 | 249 | then |
|
249 | 250 | tools/release upload |
|
250 | 251 | fi |
|
251 | 252 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now