.. _invalid-str-returned:

invalid-str-returned / E0307
============================

**Message emitted:**

__str__ does not return str

**Description:**

*Used when a __str__ method returns something which is not a string*

**Problematic code:**

.. literalinclude:: /data/messages/i/invalid-str-returned/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/i/invalid-str-returned/good.py
   :language: python



Created by the `classes <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/classes/special_methods_checker.py>`__ checker.