uselotus / lotus

File .deepsource.toml not found in the default branch of the repository root. Please refer to the docs.

Inconsistent return statements PYL-R1710
Style
Minor
a year agoa year old
Either all return statements in a function should return an expression, or none of them should.
 31        raise Exception(f"can't convert type {type(value)} into date")
 32
 33
 34def convert_to_datetime(value, date_behavior="min"): 35    if isinstance(value, datetime.datetime):
 36        return value.replace(tzinfo=pytz.UTC)
 37    elif isinstance(value, str):
Either all return statements in a function should return an expression, or none of them should.
196    return str(now_utc().timestamp())
197
198
199def calculate_end_date(interval, start_date):200    if interval == PLAN_DURATION.MONTHLY:
201        return start_date + relativedelta(months=+1)
202    elif interval == PLAN_DURATION.QUARTERLY:
Either all return statements in a function should return an expression, or none of them should.
12    def __init__(self, User):
13        self.User = User
14
15    def get(self, user_id=None, email=None):16        try:
17            if user_id:
18                return self.User.objects.get(id=user_id)
Either all return statements in a function should return an expression, or none of them should.
 949                + str(self.price_adjustment_type)
 950            )
 951
 952    def apply(self, amount): 953        if self.price_adjustment_type == PRICE_ADJUSTMENT_TYPE.PERCENTAGE:
 954            return amount * (1 + self.price_adjustment_amount / 100)
 955        elif self.price_adjustment_type == PRICE_ADJUSTMENT_TYPE.FIXED:
Either all return statements in a function should return an expression, or none of them should.
11    Source: https://stackoverflow.com/a/35836674/59984
12    """
13
14    def authenticate(self, request, username=None, password=None, **kwargs):15        # n.b. Django <2.1 does not pass the `request`
16
17        user_model = get_user_model()