Python developer mode
The Python Development Mode introduces additional runtime checks that are too expensive to be enabled by default. It should not be more verbose than the default if the code is correct; new warnings are only emitted when an issue is detected.
It can be enabled using the
-X devcommand line option or by setting thePYTHONDEVMODEenvironment variable to1.
Some of the more useful things this does for typical Python development includes the following:
Add
defaultwarning filter.
- The following warnings are shown:
- Normally, the above warnings are filtered by the default warning filters.
- It behaves as if the
-W defaultcommand line option is used.- Use the
-W errorcommand line option or set thePYTHONWARNINGSenvironment variable toerrorto treat warnings as errors.Enable asyncio debug mode. For example,
asynciochecks for coroutines that were not awaited and logs them.
- It behaves as if the
PYTHONASYNCIODEBUGenvironment variable is set to1.Check the encoding and errors arguments for string encoding and decoding operations. Examples:
open(),str.encode()andbytes.decode().
- By default, for best performance, the errors argument is only checked at the first encoding/decoding error and the encoding argument is sometimes ignored for empty strings.