Skip to main content

Configurable postfix completion extension for IPython.

Project description

IPython Postfix Completion

Configurable postfix completion extension for IPython.

Package on PyPI: ipython-postfix-completion

Install

Install into the current Python environment with uv:

uvx --with ipython-postfix-completion ipython

Install into the current ipython environment with uv:

uv tool install ipython --with ipython-postfix-completion

Load

Inside IPython:

%load_ext ipython_postfix_completion

To load it automatically, add this to ipython_config.py:

c.InteractiveShellApp.extensions = ["ipython_postfix_completion"]

Quick Example: Add a for Template

Add a template for the current IPython session:

%postfix_template add for "for item in {expr}:\n{indent}    "

Use it:

items.for<Tab>

It expands to:

for item in items:
    

Runtime templates only affect the current IPython session. Put templates in ipython_config.py if you want them to persist.

Runtime Magic

List effective templates:

%postfix_template list

Add or override a template for the current session:

%postfix_template add debug "print({expr}=)"
%postfix_template add forin "for item in {expr}:\n{indent}    "

Disable a template for the current session:

%postfix_template remove tuple

Reset one runtime change:

%postfix_template reset forin

Reset all runtime changes:

%postfix_template reset --all

Persistent Config

Add persistent templates in ipython_config.py:

c.PostfixCompletionConfig.templates = {
    "debug": "print({expr}=)",
    "forin": "for item in {expr}:\n{indent}    ",
}

c.PostfixCompletionConfig.disabled_templates = ["tuple"]

Template names must match [A-Za-z_][A-Za-z0-9_]*.

Templates must include {expr} and may also use {indent}. No other template fields are allowed.

Built-in Templates

Default templates:

Name Expansion
print print({expr})
len len({expr})
not not {expr}
par ({expr})
var {expr} =
await await {expr}
return return {expr}
if if {expr}:\n{indent}
while while {expr}:\n{indent}
raise raise {expr}
yield yield {expr}
str str({expr})
list list({expr})
set set({expr})
dict dict({expr})
tuple tuple({expr})

Use %postfix_template list in IPython to see the exact effective set, including custom and disabled templates.

Local Validation

Run tests:

uv run --extra test pytest -q

Build and check release artifacts:

uv run --extra dev python -m build
uv run --extra dev python -m twine check dist/*

Validate the wheel in a clean local virtual environment:

uv venv .venv-check
uv pip install --python .venv-check/bin/python dist/*.whl
.venv-check/bin/ipython

Then inside IPython:

%load_ext ipython_postfix_completion
%postfix_template add for "for item in {expr}:\n{indent}    "
%postfix_template list

Publish

Publishing uses GitHub Actions and PyPI Trusted Publishing. Configure the existing PyPI project once under Manage > Publishing > Add a new publisher:

Setting Value
Owner fishandsheep
Repository ipython-postfix-completion
Workflow publish.yml
Environment pypi

For each release, update project.version in pyproject.toml, commit and push the change, then create a matching v tag. For example, after changing the version to 0.1.1:

git tag v0.1.1
git push origin v0.1.1

The workflow verifies the tag against project.version, runs tests, builds and checks both distributions, then publishes them to PyPI using a short-lived OIDC credential. The already-published 0.1.0 release cannot be uploaded again.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipython_postfix_completion-0.1.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipython_postfix_completion-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file ipython_postfix_completion-0.1.1.tar.gz.

File metadata

File hashes

Hashes for ipython_postfix_completion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0813285e1632b519cb58bd8b4a05207210935853cbc345dad183917c0092b127
MD5 17b89fc0e6b4e94b3f3bb8a4c729e5fd
BLAKE2b-256 88c98b9a2758c8b01fc68f3ec5ffb8007382b0c39c40708173e835540783bd2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipython_postfix_completion-0.1.1.tar.gz:

Publisher: publish.yml on fishandsheep/ipython-postfix-completion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipython_postfix_completion-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ipython_postfix_completion-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15e591a4f41bb68fcbe6a42e2d92e245469f4456e92559d2a5637980bfb1efdb
MD5 fc43b44b9c50f1344d2391d3cbad2bf9
BLAKE2b-256 e548cc245b7e4f9b7ce6dd349b97a3044d906034df7271bc51d4cf986583f657

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipython_postfix_completion-0.1.1-py3-none-any.whl:

Publisher: publish.yml on fishandsheep/ipython-postfix-completion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page