Skip to content

Warnings should provide a stacklevel #2106

Closed
@hynek

Description

Long story short

Warnings have useless frame/position information.

Expected behaviour

Warnings should point to my code so I know what to fix.

Actual behaviour

Warnings point to aiohttp’s lines where the warnings are raised (like aiohttp/helpers.py:129: DeprecationWarning: ClientSession.close() is a coroutine) which makes them rather useless. That’s because warnings.warn is called with the default stacklevel value of 1. It’s a rather unknown option but makes the warnings incredibly more useful. :) See also: https://docs.python.org/3/library/warnings.html#warnings.warn for an example.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions