Skip to content

gh-149189: Modern defaults for pprint#149190

Open
hugovk wants to merge 2 commits intopython:mainfrom
hugovk:3.15-pprint-defaults
Open

gh-149189: Modern defaults for pprint#149190
hugovk wants to merge 2 commits intopython:mainfrom
hugovk:3.15-pprint-defaults

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Apr 30, 2026

Given:

from pprint import pprint

config = {
    "database": {
        "host": "db.example.com",
        "port": 5432,
        "options": {
            "connect_timeout": 5,
            "pool_size": 10,
            "ssl": True,
            "sslmode": "verify-full",
        },
    },
    "logging": {
        "level": "INFO",
        "file": "/var/log/app.log",
        "handlers": {
            "console": {"enabled": True},
            "file": {"rotate": True, "max_bytes": 1048576},
        },
    },
}

print("===== expand=False =====")
print()
pprint(config)

print()

print("===== expand=True =====")
print()
pprint(config, expand=True)

main produces:

{'database': {'host': 'db.example.com',
              'options': {'connect_timeout': 5,
                          'pool_size': 10,
                          'ssl': True,
                          'sslmode': 'verify-full'},
              'port': 5432},
 'logging': {'file': '/var/log/app.log',
             'handlers': {'console': {'enabled': True},
                          'file': {'max_bytes': 1048576, 'rotate': True}},
             'level': 'INFO'}}

This PR produces:

{
    'database': {
        'host': 'db.example.com',
        'options': {'connect_timeout': 5, 'pool_size': 10, 'ssl': True, 'sslmode': 'verify-full'},
        'port': 5432,
    },
    'logging': {
        'file': '/var/log/app.log',
        'handlers': {'console': {'enabled': True}, 'file': {'max_bytes': 1048576, 'rotate': True}},
        'level': 'INFO',
    },
}

@hugovk hugovk requested a review from cjw296 as a code owner April 30, 2026 16:00
@hugovk hugovk added the stdlib Standard Library Python modules in the Lib/ directory label Apr 30, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Apr 30, 2026

@hugovk hugovk force-pushed the 3.15-pprint-defaults branch from 89842d3 to 3f04477 Compare April 30, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant