String conversion without dunder method
Reports when a type that doesn't define __str__, __repr__, or __format__ is converted to a string. The default string representation may not be useful for debugging or display purposes.
The inspection does not report when a type comes from a type stub that has no runtime module. Such a stub usually omits a __str__ and a __repr__ that only override the object ones, so the IDE cannot know what the type defines.
Example:
Consider defining one of these methods to provide a meaningful string representation:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
PyStringConversionWithoutDunderMethod- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection ID: PyStringConversionWithoutDunderMethodInspection
Inspection options
Here you can find the description of settings available for the String conversion without dunder method inspection, and the reference of their default values.
- Ignored types
Option ID:
ignoredTypesDefault value:
None- Reported types
Option ID:
reportedTypesDefault value:
[builtins.object, types.FunctionType, builtins.type]
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: | CLion 2026.3, IntelliJ IDEA 2026.3, PyCharm 2026.3, Qodana for JVM 2026.3, |