.. _boolean-datetime:

boolean-datetime / W1502
========================

**Message emitted:**

``Using datetime.time in a boolean context.``

**Description:**

*Using datetime.time in a boolean context can hide subtle bugs when the time they represent matches midnight UTC. This behaviour was fixed in Python 3.5. See https://bugs.python.org/issue13936 for reference.*

**Problematic code:**

.. literalinclude:: /data/messages/b/boolean-datetime/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/b/boolean-datetime/good.py
   :language: python

**Configuration file:**

.. literalinclude:: /data/messages/b/boolean-datetime/pylintrc
    :language: ini


**Related links:**

- `Python bug tracker <https://bugs.python.org/issue13936>`_


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