Skip to content

Commit

Permalink
some typing
Browse files Browse the repository at this point in the history
  • Loading branch information
jieter committed Nov 6, 2024
1 parent 527c746 commit da79d65
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions django_tables2/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import inspect
import warnings
from collections import OrderedDict
from collections.abc import Callable
from functools import total_ordering
from itertools import chain
from typing import Any

from django.core.exceptions import FieldDoesNotExist
from django.db import models
Expand Down Expand Up @@ -530,8 +532,10 @@ def segment(sequence, aliases):
yield tuple([valias])


def signature(fn):
def signature(fn: Callable) -> tuple[tuple, str]:
"""
Return argument names and the name of the kwargs catch all.
Returns:
tuple: Returns a (arguments, kwarg_name)-tuple:
- the arguments (positional or keyword)
Expand All @@ -555,9 +559,9 @@ def signature(fn):
return tuple(args), keywords


def call_with_appropriate(fn, kwargs):
def call_with_appropriate(fn: Callable, kwargs: dict[str, Any]):
"""
Calls the function ``fn`` with the keyword arguments from ``kwargs`` it expects
Calls the function ``fn`` with the keyword arguments from ``kwargs`` it expects.
If the kwargs argument is defined, pass all arguments, else provide exactly
the arguments wanted.
Expand All @@ -577,9 +581,9 @@ def call_with_appropriate(fn, kwargs):
return fn(**kwargs)


def computed_values(d, kwargs=None):
def computed_values(d: dict[str, Any], kwargs=None) -> dict[str, Any]:
"""
Returns a new `dict` that has callable values replaced with the return values.
Returns a new `dict` that has callable values replaced with their return values.
Example::
Expand Down

0 comments on commit da79d65

Please sign in to comment.