mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
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:
parent
6485894157
commit
aff649a3bd
@ -1,4 +1,4 @@
|
|||||||
import functools
|
from functools import wraps
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from inspect import getfullargspec, unwrap
|
from inspect import getfullargspec, unwrap
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class Library:
|
|||||||
) = getfullargspec(unwrap(func))
|
) = getfullargspec(unwrap(func))
|
||||||
function_name = name or func.__name__
|
function_name = name or func.__name__
|
||||||
|
|
||||||
@functools.wraps(func)
|
@wraps(func)
|
||||||
def compile_func(parser, token):
|
def compile_func(parser, token):
|
||||||
bits = token.split_contents()[1:]
|
bits = token.split_contents()[1:]
|
||||||
target_var = None
|
target_var = None
|
||||||
@ -175,7 +175,7 @@ class Library:
|
|||||||
) = getfullargspec(unwrap(func))
|
) = getfullargspec(unwrap(func))
|
||||||
function_name = name or func.__name__
|
function_name = name or func.__name__
|
||||||
|
|
||||||
@functools.wraps(func)
|
@wraps(func)
|
||||||
def compile_func(parser, token):
|
def compile_func(parser, token):
|
||||||
bits = token.split_contents()[1:]
|
bits = token.split_contents()[1:]
|
||||||
args, kwargs = parse_bits(
|
args, kwargs = parse_bits(
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import functools
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -10,6 +9,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
import weakref
|
import weakref
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from functools import lru_cache, wraps
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from zipimport import zipimporter
|
from zipimport import zipimporter
|
||||||
@ -57,7 +57,7 @@ def is_django_path(path):
|
|||||||
|
|
||||||
|
|
||||||
def check_errors(fn):
|
def check_errors(fn):
|
||||||
@functools.wraps(fn)
|
@wraps(fn)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
global _exception
|
global _exception
|
||||||
try:
|
try:
|
||||||
@ -120,7 +120,7 @@ def iter_all_python_module_files():
|
|||||||
return iter_modules_and_files(modules, frozenset(_error_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):
|
def iter_modules_and_files(modules, extra_files):
|
||||||
"""Iterate through all modules needed to be watched."""
|
"""Iterate through all modules needed to be watched."""
|
||||||
sys_file_paths = []
|
sys_file_paths = []
|
||||||
@ -170,7 +170,7 @@ def iter_modules_and_files(modules, extra_files):
|
|||||||
return frozenset(results)
|
return frozenset(results)
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
def common_roots(paths):
|
def common_roots(paths):
|
||||||
"""
|
"""
|
||||||
Return a tuple of common roots that are shared between the given 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)
|
logger.debug("Watchman watch-project result: %s", result)
|
||||||
return result["watch"], result.get("relative_path")
|
return result["watch"], result.get("relative_path")
|
||||||
|
|
||||||
@functools.lru_cache
|
@lru_cache
|
||||||
def _get_clock(self, root):
|
def _get_clock(self, root):
|
||||||
return self.client.query("clock", root)["clock"]
|
return self.client.query("clock", root)["clock"]
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import functools
|
from functools import wraps
|
||||||
|
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ def sensitive_variables(*variables):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
@functools.wraps(func)
|
@wraps(func)
|
||||||
def sensitive_variables_wrapper(*func_args, **func_kwargs):
|
def sensitive_variables_wrapper(*func_args, **func_kwargs):
|
||||||
if variables:
|
if variables:
|
||||||
sensitive_variables_wrapper.sensitive_variables = variables
|
sensitive_variables_wrapper.sensitive_variables = variables
|
||||||
@ -77,7 +77,7 @@ def sensitive_post_parameters(*parameters):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def decorator(view):
|
def decorator(view):
|
||||||
@functools.wraps(view)
|
@wraps(view)
|
||||||
def sensitive_post_parameters_wrapper(request, *args, **kwargs):
|
def sensitive_post_parameters_wrapper(request, *args, **kwargs):
|
||||||
if not isinstance(request, HttpRequest):
|
if not isinstance(request, HttpRequest):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import functools
|
|
||||||
import os
|
import os
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
from django.template.engine import Engine
|
from django.template.engine import Engine
|
||||||
from django.test.utils import override_settings
|
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
|
# Make Engine.get_default() raise an exception to ensure that tests
|
||||||
# are properly isolated from Django's global settings.
|
# are properly isolated from Django's global settings.
|
||||||
@override_settings(TEMPLATES=None)
|
@override_settings(TEMPLATES=None)
|
||||||
@functools.wraps(func)
|
@wraps(func)
|
||||||
def inner(self):
|
def inner(self):
|
||||||
# Set up custom template tag libraries if specified
|
# Set up custom template tag libraries if specified
|
||||||
libraries = getattr(self, "libraries", {})
|
libraries = getattr(self, "libraries", {})
|
||||||
|
Loading…
Reference in New Issue
Block a user