Skip to content

utils.timesince.timesince should accept an optional integer depth #895

@andylolz

Description

@andylolz

Bug report

What's wrong

My code looks like this:

from django.utils.timesince import timesince

timesince(d, now, depth=1)

When I run mypy, I see the following error:

error: Unexpected keyword argument "depth" for "timesince"
env/lib/python3.10/site-packages/django-stubs/utils/timesince.pyi:7: note: "timesince" defined here

It looks like the depth argument was added at django 3.2: django/django@8fa9a6d

The django-stubs definition doesn’t include the depth argument:

def timesince(
d: date, now: Optional[date] = ..., reversed: bool = ..., time_strings: Optional[Dict[str, str]] = ...
) -> str: ...

How it should be

I guess the timesince definition should look like this:

def timesince( 
     d: date, now: Optional[date] = ..., reversed: bool = ..., time_strings: Optional[Dict[str, str]] = ..., depth: Optional[int] = ...
 ) -> str: ...

The same issue applies to utils.timesince.timeuntil.

System information

  • python version: 3.10
  • django version: 3.2
  • mypy version: 0.941
  • django-stubs version: 1.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions