summaryrefslogtreecommitdiff
path: root/pylint/test/functional/boolean_datetime.py
blob: 0ca5c38b5d9e7dba112bfbac6f32d8538022a5a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
""" Checks for boolean uses of datetime.time. """
# pylint: disable=superfluous-parens,print-statement,no-absolute-import
import datetime

if datetime.time(0, 0, 0): # [boolean-datetime]
    print("datetime.time(0,0,0) is not a bug!")
else:
    print("datetime.time(0,0,0) is a bug!")

if not datetime.time(0, 0, 1): # [boolean-datetime]
    print("datetime.time(0,0,1) is not a bug!")
else:
    print("datetime.time(0,0,1) is a bug!")

DATA = not datetime.time(0, 0, 0) # [boolean-datetime]
DATA = True if datetime.time(0, 0, 0) else False # [boolean-datetime]
DATA = datetime.time(0, 0, 0) or True # [boolean-datetime]
DATA = datetime.time(0, 0, 0) and True # [boolean-datetime]
DATA = False or True or datetime.time(0, 0, 0) # [boolean-datetime]
DATA = False and datetime.time(0, 0, 0) or True # [boolean-datetime]


def cant_infer(data):
    """ Can't infer what data is """
    hophop = not data
    troptrop = True if data else False
    toptop = data or True
    return hophop, troptrop, toptop

cant_infer(datetime.time(0, 0, 0))