1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Used Signature API instead of deprecated inspect.getcallargs().

inspect.getcallargs() was deprecated in Python 3.5 and the Signature
API (PEP 362) has better support for decorated functions (by default,
it follows the __wrapped__ attribute set by functools.wraps for
example).
This commit is contained in:
Baptiste Mispelon 2019-12-10 09:25:07 +01:00 committed by Mariusz Felisiak
parent 3df3c5e670
commit 09341856ed
2 changed files with 4 additions and 4 deletions

View File

@ -1916,9 +1916,8 @@ class Query(BaseExpression):
group_by = list(self.select) group_by = list(self.select)
if self.annotation_select: if self.annotation_select:
for alias, annotation in self.annotation_select.items(): for alias, annotation in self.annotation_select.items():
try: signature = inspect.signature(annotation.get_group_by_cols)
inspect.getcallargs(annotation.get_group_by_cols, alias=alias) if 'alias' not in signature.parameters:
except TypeError:
annotation_class = annotation.__class__ annotation_class = annotation.__class__
msg = ( msg = (
'`alias=None` must be added to the signature of ' '`alias=None` must be added to the signature of '

View File

@ -857,8 +857,9 @@ class Variable:
try: # method call (assuming no args required) try: # method call (assuming no args required)
current = current() current = current()
except TypeError: except TypeError:
signature = inspect.signature(current)
try: try:
inspect.getcallargs(current) signature.bind()
except TypeError: # arguments *were* required except TypeError: # arguments *were* required
current = context.template.engine.string_if_invalid # invalid method call current = context.template.engine.string_if_invalid # invalid method call
else: else: