Inspectopedia 2026.1 Help

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.

Example:

class A: pass str(A()) # Result: "<__main__.A object at 0x...>"

Consider defining one of these methods to provide a meaningful string representation:

class A: def __str__(self): return "A instance" def __repr__(self): return "A()"

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.

Settings or Preferences | Editor | Inspections | Python

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:

ignoredTypes

Default value:

[types.NoneType, _io.TextIOWrapper, str, int, float, complex, set, frozenset, bytes, bytearray, memoryview, slice, list, dict, bool, range, tuple]
Reported types

Option ID:

reportedTypes

Default value:

[types.FunctionType, 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:

//noinspection PyStringConversionWithoutDunderMethod

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Last modified: 31 March 2026