Normalized imports of functools.wraps.

@wraps is 10 times more common than @functools.wraps. Standardize to
the most common version.
This commit is contained in:
Aymeric Augustin 2022-05-22 08:23:10 +02:00 committed by Mariusz Felisiak
parent 6485894157
commit aff649a3bd
4 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import functools
from functools import wraps
from importlib import import_module
from inspect import getfullargspec, unwrap
@ -120,7 +120,7 @@ class Library:
) = getfullargspec(unwrap(func))
function_name = name or func.__name__
@functools.wraps(func)
@wraps(func)
def compile_func(parser, token):
bits = token.split_contents()[1:]
target_var = None
@ -175,7 +175,7 @@ class Library:
) = getfullargspec(unwrap(func))
function_name = name or func.__name__
@functools.wraps(func)
@wraps(func)
def compile_func(parser, token):
bits = token.split_contents()[1:]
args, kwargs = parse_bits(

View File

@ -1,4 +1,3 @@
import functools
import itertools
import logging
import os
@ -10,6 +9,7 @@ import time
import traceback
import weakref
from collections import defaultdict
from functools import lru_cache, wraps
from pathlib import Path
from types import ModuleType
from zipimport import zipimporter
@ -57,7 +57,7 @@ def is_django_path(path):
def check_errors(fn):
@functools.wraps(fn)
@wraps(fn)
def wrapper(*args, **kwargs):
global _exception
try:
@ -120,7 +120,7 @@ def iter_all_python_module_files():
return iter_modules_and_files(modules, frozenset(_error_files))
@functools.lru_cache(maxsize=1)
@lru_cache(maxsize=1)
def iter_modules_and_files(modules, extra_files):
"""Iterate through all modules needed to be watched."""
sys_file_paths = []
@ -170,7 +170,7 @@ def iter_modules_and_files(modules, extra_files):
return frozenset(results)
@functools.lru_cache(maxsize=1)
@lru_cache(maxsize=1)
def common_roots(paths):
"""
Return a tuple of common roots that are shared between the given paths.
@ -463,7 +463,7 @@ class WatchmanReloader(BaseReloader):
logger.debug("Watchman watch-project result: %s", result)
return result["watch"], result.get("relative_path")
@functools.lru_cache
@lru_cache
def _get_clock(self, root):
return self.client.query("clock", root)["clock"]

View File

@ -1,4 +1,4 @@
import functools
from functools import wraps
from django.http import HttpRequest
@ -33,7 +33,7 @@ def sensitive_variables(*variables):
)
def decorator(func):
@functools.wraps(func)
@wraps(func)
def sensitive_variables_wrapper(*func_args, **func_kwargs):
if variables:
sensitive_variables_wrapper.sensitive_variables = variables
@ -77,7 +77,7 @@ def sensitive_post_parameters(*parameters):
)
def decorator(view):
@functools.wraps(view)
@wraps(view)
def sensitive_post_parameters_wrapper(request, *args, **kwargs):
if not isinstance(request, HttpRequest):
raise TypeError(

View File

@ -1,5 +1,5 @@
import functools
import os
from functools import wraps
from django.template.engine import Engine
from django.test.utils import override_settings
@ -46,7 +46,7 @@ def setup(templates, *args, test_once=False):
# Make Engine.get_default() raise an exception to ensure that tests
# are properly isolated from Django's global settings.
@override_settings(TEMPLATES=None)
@functools.wraps(func)
@wraps(func)
def inner(self):
# Set up custom template tag libraries if specified
libraries = getattr(self, "libraries", {})