diff --git a/.github/linters/tox.ini b/.github/linters/tox.ini index 8341c3bef..e024de18f 100644 --- a/.github/linters/tox.ini +++ b/.github/linters/tox.ini @@ -32,7 +32,7 @@ exclude = venv*, scripts -max-line-length = 80 +max-line-length = 88 per-file-ignores = # import not used diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 6860bdb0e..000000000 --- a/.isort.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[settings] -profile = black \ No newline at end of file diff --git a/azure_functions_worker/_thirdparty/typing_inspect.py b/azure_functions_worker/_thirdparty/typing_inspect.py index e9651e75f..f5ae783d2 100644 --- a/azure_functions_worker/_thirdparty/typing_inspect.py +++ b/azure_functions_worker/_thirdparty/typing_inspect.py @@ -11,11 +11,9 @@ # NOTE: This module must support Python 2.7 in addition to Python 3.x -import sys import collections.abc -from typing import ( - Generic, Callable, Union, TypeVar, ClassVar, Tuple, _GenericAlias -) +import sys +from typing import Callable, ClassVar, Generic, Tuple, TypeVar, Union, _GenericAlias NEW_39_TYPING = sys.version_info[:3] >= (3, 9, 0) # PEP 560 if NEW_39_TYPING: diff --git a/azure_functions_worker/bindings/__init__.py b/azure_functions_worker/bindings/__init__.py index c1f667c16..e64ba3bd6 100644 --- a/azure_functions_worker/bindings/__init__.py +++ b/azure_functions_worker/bindings/__init__.py @@ -1,18 +1,22 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from .tracecontext import TraceContext -from .retrycontext import RetryContext +from .retrycontext import RetryContext # isort: skip +from .tracecontext import TraceContext # isort: skip from .context import Context -from .meta import check_input_type_annotation -from .meta import check_output_type_annotation -from .meta import has_implicit_output -from .meta import is_trigger_binding, load_binding_registry -from .meta import from_incoming_proto, to_outgoing_proto, \ - to_outgoing_param_binding, check_deferred_bindings_enabled, \ - get_deferred_raw_bindings +from .meta import ( + check_deferred_bindings_enabled, + check_input_type_annotation, + check_output_type_annotation, + from_incoming_proto, + get_deferred_raw_bindings, + has_implicit_output, + is_trigger_binding, + load_binding_registry, + to_outgoing_param_binding, + to_outgoing_proto, +) from .out import Out - __all__ = ( 'Out', 'Context', 'is_trigger_binding', diff --git a/azure_functions_worker/bindings/context.py b/azure_functions_worker/bindings/context.py index 76a93a16c..7effbf76d 100644 --- a/azure_functions_worker/bindings/context.py +++ b/azure_functions_worker/bindings/context.py @@ -3,8 +3,7 @@ import threading from typing import Type -from . import TraceContext -from . import RetryContext +from . import RetryContext, TraceContext class Context: diff --git a/azure_functions_worker/bindings/datumdef.py b/azure_functions_worker/bindings/datumdef.py index 48136e8bd..34fb9b0af 100644 --- a/azure_functions_worker/bindings/datumdef.py +++ b/azure_functions_worker/bindings/datumdef.py @@ -1,19 +1,26 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import logging -from typing import Any, Optional import json +import logging +from typing import Any, List, Optional + from .. import protos from ..logging import logger -from typing import List + try: from http.cookies import SimpleCookie except ImportError: from Cookie import SimpleCookie + from dateutil import parser from dateutil.parser import ParserError -from .nullable_converters import to_nullable_bool, to_nullable_string, \ - to_nullable_double, to_nullable_timestamp + +from .nullable_converters import ( + to_nullable_bool, + to_nullable_double, + to_nullable_string, + to_nullable_timestamp, +) class Datum: diff --git a/azure_functions_worker/bindings/generic.py b/azure_functions_worker/bindings/generic.py index 901b15e78..d5a0f8ab7 100644 --- a/azure_functions_worker/bindings/generic.py +++ b/azure_functions_worker/bindings/generic.py @@ -1,9 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import typing +from typing import Any, Optional from . import datumdef -from typing import Any, Optional class GenericBinding: diff --git a/azure_functions_worker/bindings/meta.py b/azure_functions_worker/bindings/meta.py index c6148344d..7d4be3273 100644 --- a/azure_functions_worker/bindings/meta.py +++ b/azure_functions_worker/bindings/meta.py @@ -4,17 +4,17 @@ import sys import typing - from .. import protos -from . import datumdef -from . import generic - -from .shared_memory_data_transfer import SharedMemoryManager +from ..constants import ( + BASE_EXT_SUPPORTED_PY_MINOR_VERSION, + CUSTOMER_PACKAGES_PATH, + HTTP, + HTTP_TRIGGER, +) from ..http_v2 import HttpV2Registry -from ..constants import CUSTOMER_PACKAGES_PATH, HTTP, HTTP_TRIGGER, \ - BASE_EXT_SUPPORTED_PY_MINOR_VERSION from ..logging import logger - +from . import datumdef, generic +from .shared_memory_data_transfer import SharedMemoryManager PB_TYPE = 'rpc_data' PB_TYPE_DATA = 'data' diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/__init__.py b/azure_functions_worker/bindings/shared_memory_data_transfer/__init__.py index bc98616a4..a68b5ec4e 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/__init__.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/__init__.py @@ -12,12 +12,12 @@ https://github.com/Azure/azure-functions-host/issues/6791 """ -from .file_accessor_factory import FileAccessorFactory from .file_accessor import FileAccessor +from .file_accessor_factory import FileAccessorFactory from .shared_memory_constants import SharedMemoryConstants from .shared_memory_exception import SharedMemoryException -from .shared_memory_map import SharedMemoryMap from .shared_memory_manager import SharedMemoryManager +from .shared_memory_map import SharedMemoryMap __all__ = ( 'FileAccessorFactory', 'FileAccessor', 'SharedMemoryConstants', diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor.py b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor.py index e5ea15597..3838bcdaa 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor.py @@ -4,6 +4,7 @@ import mmap from abc import ABCMeta, abstractmethod from typing import Optional + from .shared_memory_constants import SharedMemoryConstants as consts diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_factory.py b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_factory.py index 1c0340222..eb97f0f54 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_factory.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_factory.py @@ -4,11 +4,11 @@ import os import sys +from ...constants import FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED +from ...utils.common import is_envvar_true from .file_accessor import DummyFileAccessor from .file_accessor_unix import FileAccessorUnix from .file_accessor_windows import FileAccessorWindows -from ...constants import FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED -from ...utils.common import is_envvar_true class FileAccessorFactory: diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_unix.py b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_unix.py index aaf122108..ae4f6206c 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_unix.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_unix.py @@ -1,16 +1,18 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from azure_functions_worker import constants -import os import mmap -from typing import Optional, List +import os from io import BufferedRandom +from typing import List, Optional + +from azure_functions_worker import constants + +from ...logging import logger +from ...utils.common import get_app_setting +from .file_accessor import FileAccessor from .shared_memory_constants import SharedMemoryConstants as consts from .shared_memory_exception import SharedMemoryException -from .file_accessor import FileAccessor -from ...utils.common import get_app_setting -from ...logging import logger class FileAccessorUnix(FileAccessor): diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_windows.py b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_windows.py index dfd3ed3af..1b45056c7 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_windows.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_windows.py @@ -3,9 +3,10 @@ import mmap from typing import Optional -from .shared_memory_exception import SharedMemoryException -from .file_accessor import FileAccessor + from ...logging import logger +from .file_accessor import FileAccessor +from .shared_memory_exception import SharedMemoryException class FileAccessorWindows(FileAccessor): diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_manager.py b/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_manager.py index a74027b7a..ec1a1a7cb 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_manager.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_manager.py @@ -3,14 +3,15 @@ import uuid from typing import Dict, Optional -from .shared_memory_constants import SharedMemoryConstants as consts -from .file_accessor_factory import FileAccessorFactory -from .shared_memory_metadata import SharedMemoryMetadata -from .shared_memory_map import SharedMemoryMap -from ..datumdef import Datum + +from ...constants import FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED from ...logging import logger from ...utils.common import is_envvar_true -from ...constants import FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED +from ..datumdef import Datum +from .file_accessor_factory import FileAccessorFactory +from .shared_memory_constants import SharedMemoryConstants as consts +from .shared_memory_map import SharedMemoryMap +from .shared_memory_metadata import SharedMemoryMetadata class SharedMemoryManager: diff --git a/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_map.py b/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_map.py index 751617dbc..d84eb81c4 100644 --- a/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_map.py +++ b/azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_map.py @@ -6,10 +6,11 @@ import struct import sys from typing import Optional + +from ...logging import logger +from .file_accessor import FileAccessor from .shared_memory_constants import SharedMemoryConstants as consts from .shared_memory_exception import SharedMemoryException -from .file_accessor import FileAccessor -from ...logging import logger class SharedMemoryMap: diff --git a/azure_functions_worker/dispatcher.py b/azure_functions_worker/dispatcher.py index 807985cc6..87431f17a 100644 --- a/azure_functions_worker/dispatcher.py +++ b/azure_functions_worker/dispatcher.py @@ -19,29 +19,43 @@ from typing import List, Optional import grpc + from . import bindings, constants, functions, loader, protos from .bindings.shared_memory_data_transfer import SharedMemoryManager -from .constants import (PYTHON_ROLLBACK_CWD_PATH, - PYTHON_THREADPOOL_THREAD_COUNT, - PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT, - PYTHON_THREADPOOL_THREAD_COUNT_MAX_37, - PYTHON_THREADPOOL_THREAD_COUNT_MIN, - PYTHON_ENABLE_DEBUG_LOGGING, - PYTHON_SCRIPT_FILE_NAME, - PYTHON_SCRIPT_FILE_NAME_DEFAULT, - PYTHON_LANGUAGE_RUNTIME, PYTHON_ENABLE_INIT_INDEXING, - METADATA_PROPERTIES_WORKER_INDEXED, - PYTHON_ENABLE_OPENTELEMETRY, - PYTHON_ENABLE_OPENTELEMETRY_DEFAULT) +from .constants import ( + METADATA_PROPERTIES_WORKER_INDEXED, + PYTHON_ENABLE_DEBUG_LOGGING, + PYTHON_ENABLE_INIT_INDEXING, + PYTHON_ENABLE_OPENTELEMETRY, + PYTHON_ENABLE_OPENTELEMETRY_DEFAULT, + PYTHON_LANGUAGE_RUNTIME, + PYTHON_ROLLBACK_CWD_PATH, + PYTHON_SCRIPT_FILE_NAME, + PYTHON_SCRIPT_FILE_NAME_DEFAULT, + PYTHON_THREADPOOL_THREAD_COUNT, + PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT, + PYTHON_THREADPOOL_THREAD_COUNT_MAX_37, + PYTHON_THREADPOOL_THREAD_COUNT_MIN, +) from .extension import ExtensionManager -from .http_v2 import http_coordinator, initialize_http_server, HttpV2Registry, \ - sync_http_request, HttpServerInitError -from .logging import disable_console_logging, enable_console_logging -from .logging import (logger, error_logger, is_system_log_category, - CONSOLE_LOG_PREFIX, format_exception) +from .http_v2 import ( + HttpServerInitError, + HttpV2Registry, + http_coordinator, + initialize_http_server, + sync_http_request, +) +from .logging import ( + CONSOLE_LOG_PREFIX, + disable_console_logging, + enable_console_logging, + error_logger, + format_exception, + is_system_log_category, + logger, +) from .utils.app_setting_manager import get_python_appsetting_state -from .utils.common import (get_app_setting, is_envvar_true, - validate_script_file_name) +from .utils.common import get_app_setting, is_envvar_true, validate_script_file_name from .utils.dependency import DependencyManager from .utils.tracing import marshall_exception_trace from .utils.wrappers import disable_feature_by @@ -280,7 +294,8 @@ def update_opentelemetry_status(self): try: from opentelemetry import context as context_api from opentelemetry.trace.propagation.tracecontext import ( - TraceContextTextMapPropagator) + TraceContextTextMapPropagator, + ) self._context_api = context_api self._trace_context_propagator = TraceContextTextMapPropagator() diff --git a/azure_functions_worker/extension.py b/azure_functions_worker/extension.py index 568b94f90..fcf8602c0 100644 --- a/azure_functions_worker/extension.py +++ b/azure_functions_worker/extension.py @@ -7,17 +7,13 @@ from typing import Any, Callable, List, Optional from .constants import ( - PYTHON_ISOLATE_WORKER_DEPENDENCIES, PYTHON_ENABLE_WORKER_EXTENSIONS, PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT, - PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39 -) -from .logging import logger, SYSTEM_LOG_PREFIX -from .utils.common import ( - is_python_version, - get_sdk_from_sys_path, - get_sdk_version + PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39, + PYTHON_ISOLATE_WORKER_DEPENDENCIES, ) +from .logging import SYSTEM_LOG_PREFIX, logger +from .utils.common import get_sdk_from_sys_path, get_sdk_version, is_python_version from .utils.wrappers import enable_feature_by # Extension Hooks diff --git a/azure_functions_worker/functions.py b/azure_functions_worker/functions.py index cbfef029c..292fe4857 100644 --- a/azure_functions_worker/functions.py +++ b/azure_functions_worker/functions.py @@ -6,10 +6,10 @@ import typing import uuid -from .constants import HTTP_TRIGGER from . import bindings as bindings_utils from . import protos from ._thirdparty import typing_inspect +from .constants import HTTP_TRIGGER from .protos import BindingInfo diff --git a/azure_functions_worker/http_v2.py b/azure_functions_worker/http_v2.py index d7fff59b6..2aaf18bda 100644 --- a/azure_functions_worker/http_v2.py +++ b/azure_functions_worker/http_v2.py @@ -8,8 +8,11 @@ import sys from typing import Dict -from azure_functions_worker.constants import X_MS_INVOCATION_ID, \ - BASE_EXT_SUPPORTED_PY_MINOR_VERSION, PYTHON_ENABLE_INIT_INDEXING +from azure_functions_worker.constants import ( + BASE_EXT_SUPPORTED_PY_MINOR_VERSION, + PYTHON_ENABLE_INIT_INDEXING, + X_MS_INVOCATION_ID, +) from azure_functions_worker.logging import logger from azure_functions_worker.utils.common import is_envvar_false diff --git a/azure_functions_worker/loader.py b/azure_functions_worker/loader.py index 76c2472e1..ce96c1406 100644 --- a/azure_functions_worker/loader.py +++ b/azure_functions_worker/loader.py @@ -10,17 +10,23 @@ import time from datetime import timedelta from os import PathLike, fspath -from typing import Optional, Dict +from typing import Dict, Optional from google.protobuf.duration_pb2 import Duration -from . import protos, functions, bindings +from . import bindings, functions, protos from .bindings.retrycontext import RetryPolicy -from .utils.common import get_app_setting -from .constants import MODULE_NOT_FOUND_TS_URL, PYTHON_SCRIPT_FILE_NAME, \ - PYTHON_SCRIPT_FILE_NAME_DEFAULT, PYTHON_LANGUAGE_RUNTIME, \ - CUSTOMER_PACKAGES_PATH, RETRY_POLICY, METADATA_PROPERTIES_WORKER_INDEXED +from .constants import ( + CUSTOMER_PACKAGES_PATH, + METADATA_PROPERTIES_WORKER_INDEXED, + MODULE_NOT_FOUND_TS_URL, + PYTHON_LANGUAGE_RUNTIME, + PYTHON_SCRIPT_FILE_NAME, + PYTHON_SCRIPT_FILE_NAME_DEFAULT, + RETRY_POLICY, +) from .logging import logger +from .utils.common import get_app_setting from .utils.wrappers import attach_message_to_exception _AZURE_NAMESPACE = '__app__' diff --git a/azure_functions_worker/main.py b/azure_functions_worker/main.py index 3e5845a93..130e0e9ea 100644 --- a/azure_functions_worker/main.py +++ b/azure_functions_worker/main.py @@ -46,8 +46,9 @@ def main(): DependencyManager.use_worker_dependencies() import asyncio + from . import logging - from .logging import error_logger, logger, format_exception + from .logging import error_logger, format_exception, logger args = parse_args() logging.setup(log_level=args.log_level, log_destination=args.log_to) diff --git a/azure_functions_worker/utils/app_setting_manager.py b/azure_functions_worker/utils/app_setting_manager.py index 0d05bf0a2..bffec8ddf 100644 --- a/azure_functions_worker/utils/app_setting_manager.py +++ b/azure_functions_worker/utils/app_setting_manager.py @@ -3,15 +3,18 @@ import os import sys -from ..constants import (PYTHON_ROLLBACK_CWD_PATH, - PYTHON_THREADPOOL_THREAD_COUNT, - PYTHON_ISOLATE_WORKER_DEPENDENCIES, - PYTHON_ENABLE_WORKER_EXTENSIONS, - PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT, - PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39, - PYTHON_ENABLE_DEBUG_LOGGING, - FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED, - PYTHON_SCRIPT_FILE_NAME, PYTHON_ENABLE_INIT_INDEXING) +from ..constants import ( + FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED, + PYTHON_ENABLE_DEBUG_LOGGING, + PYTHON_ENABLE_INIT_INDEXING, + PYTHON_ENABLE_WORKER_EXTENSIONS, + PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT, + PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39, + PYTHON_ISOLATE_WORKER_DEPENDENCIES, + PYTHON_ROLLBACK_CWD_PATH, + PYTHON_SCRIPT_FILE_NAME, + PYTHON_THREADPOOL_THREAD_COUNT, +) def get_python_appsetting_state(): diff --git a/azure_functions_worker/utils/common.py b/azure_functions_worker/utils/common.py index c52f8199a..963cd3c1c 100644 --- a/azure_functions_worker/utils/common.py +++ b/azure_functions_worker/utils/common.py @@ -2,13 +2,15 @@ # Licensed under the MIT License. import importlib import os -import sys import re +import sys from types import ModuleType -from typing import Optional, Callable +from typing import Callable, Optional -from azure_functions_worker.constants import CUSTOMER_PACKAGES_PATH, \ - PYTHON_EXTENSIONS_RELOAD_FUNCTIONS +from azure_functions_worker.constants import ( + CUSTOMER_PACKAGES_PATH, + PYTHON_EXTENSIONS_RELOAD_FUNCTIONS, +) def is_true_like(setting: str) -> bool: diff --git a/azure_functions_worker/utils/dependency.py b/azure_functions_worker/utils/dependency.py index f977b56c9..76d4259be 100644 --- a/azure_functions_worker/utils/dependency.py +++ b/azure_functions_worker/utils/dependency.py @@ -8,13 +8,14 @@ from types import ModuleType from typing import List, Optional -from azure_functions_worker.utils.common import is_true_like, is_envvar_true +from azure_functions_worker.utils.common import is_envvar_true, is_true_like + from ..constants import ( AZURE_WEBJOBS_SCRIPT_ROOT, CONTAINER_NAME, PYTHON_ISOLATE_WORKER_DEPENDENCIES, PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT, - PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 + PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310, ) from ..logging import logger from ..utils.common import is_python_version diff --git a/azure_functions_worker/utils/tracing.py b/azure_functions_worker/utils/tracing.py index f458e4d95..0e08bf84a 100644 --- a/azure_functions_worker/utils/tracing.py +++ b/azure_functions_worker/utils/tracing.py @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from typing import List import traceback from traceback import StackSummary, extract_tb +from typing import List def extend_exception_message(exc: Exception, msg: str) -> Exception: diff --git a/azure_functions_worker/utils/wrappers.py b/azure_functions_worker/utils/wrappers.py index 7e2d8c859..29f379da3 100644 --- a/azure_functions_worker/utils/wrappers.py +++ b/azure_functions_worker/utils/wrappers.py @@ -1,11 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from typing import Callable, Any +from typing import Any, Callable -from .common import is_envvar_true, is_envvar_false -from .tracing import extend_exception_message from ..logging import error_logger, logger +from .common import is_envvar_false, is_envvar_true +from .tracing import extend_exception_message def enable_feature_by(flag: str, diff --git a/setup.py b/dev-setup.py similarity index 94% rename from setup.py rename to dev-setup.py index e75983620..86de8d2b2 100644 --- a/setup.py +++ b/dev-setup.py @@ -474,32 +474,32 @@ def run(self) -> None: f"Exception: {ex}" ) - -COMMAND_CLASS = { - "develop": Development, - "build": BuildProtos, - "webhost": Webhost, - "webhost --branch-name={branch-name}": Webhost, - "extension": Extension, - "clean": Clean, -} - -setup( - name="azure-functions-worker", - version=VERSION, - description="Python Language Worker for Azure Functions Host", - author="Azure Functions team at Microsoft Corp.", - author_email="azurefunctions@microsoft.com", - keywords="azure functions azurefunctions python serverless", - url="https://github.com/Azure/azure-functions-python-worker", - long_description=open("README.md").read(), - long_description_content_type="text/markdown", - classifiers=CLASSIFIERS, - license="MIT", - packages=PACKAGES, - install_requires=INSTALL_REQUIRES, - extras_require=EXTRA_REQUIRES, - include_package_data=True, - cmdclass=COMMAND_CLASS, - test_suite="tests", -) +# +# COMMAND_CLASS = { +# "develop": Development, +# "build": BuildProtos, +# "webhost": Webhost, +# "webhost --branch-name={branch-name}": Webhost, +# "extension": Extension, +# "clean": Clean, +# } + +# setup( +# name="azure-functions-worker", +# version=VERSION, +# description="Python Language Worker for Azure Functions Host", +# author="Azure Functions team at Microsoft Corp.", +# author_email="azurefunctions@microsoft.com", +# keywords="azure functions azurefunctions python serverless", +# url="https://github.com/Azure/azure-functions-python-worker", +# long_description=open("README.md").read(), +# long_description_content_type="text/markdown", +# classifiers=CLASSIFIERS, +# license="MIT", +# packages=PACKAGES, +# install_requires=INSTALL_REQUIRES, +# extras_require=EXTRA_REQUIRES, +# include_package_data=True, +# cmdclass=COMMAND_CLASS, +# test_suite="tests", +# ) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..3b8992353 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,119 @@ +[project] +name = "azure-functions-worker" +dynamic = ["version"] +description = "Python Language Worker for Azure Functions Runtime" +authors = [ + { name = "Azure Functions team at Microsoft Corp.", email = "azurefunctions@microsoft.com" } +] +keywords = ["azure", "functions", "azurefunctions", + "python", "serverless"] +license = { name = "MIT", file = "LICENSE" } +readme = { file = "README.md", content-type = "text/markdown" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: MacOS :: MacOS X", + "Environment :: Web Environment", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers" +] +dependencies = [ + "azure-functions==1.20.0", + "python-dateutil ~=2.9.0", + "protobuf~=3.19.3; python_version == '3.7'", + "protobuf~=4.22.0; python_version >= '3.8'", + "grpcio-tools~=1.43.0; python_version == '3.7'", + "grpcio-tools~=1.54.2; python_version >= '3.8'", + "grpcio~=1.43.0; python_version == '3.7'", + "grpcio~=1.54.2; python_version >= '3.8'", + "azurefunctions-extensions-base; python_version >= '3.8'" +] + +[project.urls] +Documentation = "https://github.com/Azure/azure-functions-python-worker?tab=readme-ov-file#-azure-functions-python-worker" +Repository = "https://github.com/Azure/azure-functions-python-worker" + +[project.optional-dependencies] +dev = [ + "azure-eventhub", # Used for EventHub E2E tests + "azure-functions-durable", # Used for Durable E2E tests + "flask", + "fastapi~=0.103.2", + "pydantic", + "pycryptodome==3.*", + "flake8==5.*", + "mypy", + "pytest~=7.4.4", + "requests==2.*", + "coverage", + "pytest-sugar", + "pytest-cov", + "pytest-xdist", + "pytest-randomly", + "pytest-instafail", + "pytest-rerunfailures", + "ptvsd", + "python-dotenv", + "plotly", + "scikit-learn", + "opencv-python", + "pandas", + "numpy", + "pre-commit" +] +test-http-v2 = [ + "azurefunctions-extensions-http-fastapi", + "ujson", + "orjson" +] +test-deferred-bindings = [ + "azurefunctions-extensions-bindings-blob" +] + +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + + +[tool.setuptools.packages.find] +exclude = [ + 'eng', 'tests', 'pack' + ] + +[tool.isort] +profile = "black" +line_length = 88 +multi_line_output = 3 +include_trailing_comma = true +known_first_party = ["azure_functions_worker"] +default_section = "THIRDPARTY" +src_paths = ["azure_functions_worker"] +skip_glob = [ + "build", + "dist", + "env", + "venv", + "*venv*", + "*.egg-info", + ".tox", + ".nox", + ".git", + "__pycache__", + ".ci", + ".devcontainer", + ".github", + "eng", + "pack", + "*protos/*" +] + +[tool.setuptools.dynamic] +version = {attr = "azure_functions_worker.version.VERSION"} diff --git a/tests/consumption_tests/test_linux_consumption.py b/tests/consumption_tests/test_linux_consumption.py index fbfd3bcea..09f10fd91 100644 --- a/tests/consumption_tests/test_linux_consumption.py +++ b/tests/consumption_tests/test_linux_consumption.py @@ -6,12 +6,13 @@ from unittest import TestCase, skipIf from requests import Request +from tests.utils.testutils_lc import LinuxConsumptionWebHostController -from azure_functions_worker.constants import PYTHON_ENABLE_INIT_INDEXING, \ - PYTHON_ENABLE_WORKER_EXTENSIONS, PYTHON_ISOLATE_WORKER_DEPENDENCIES, \ - PYTHON_ENABLE_DEBUG_LOGGING -from tests.utils.testutils_lc import ( - LinuxConsumptionWebHostController +from azure_functions_worker.constants import ( + PYTHON_ENABLE_DEBUG_LOGGING, + PYTHON_ENABLE_INIT_INDEXING, + PYTHON_ENABLE_WORKER_EXTENSIONS, + PYTHON_ISOLATE_WORKER_DEPENDENCIES, ) _DEFAULT_HOST_VERSION = "4" diff --git a/tests/endtoend/blob_functions/get_blob_as_bytes_return_http_response/main.py b/tests/endtoend/blob_functions/get_blob_as_bytes_return_http_response/main.py index a10faca86..636ac90d9 100644 --- a/tests/endtoend/blob_functions/get_blob_as_bytes_return_http_response/main.py +++ b/tests/endtoend/blob_functions/get_blob_as_bytes_return_http_response/main.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import json import hashlib +import json + import azure.functions as azf diff --git a/tests/endtoend/blob_functions/get_blob_as_bytes_stream_return_http_response/main.py b/tests/endtoend/blob_functions/get_blob_as_bytes_stream_return_http_response/main.py index 6b49a9423..eb8986c04 100644 --- a/tests/endtoend/blob_functions/get_blob_as_bytes_stream_return_http_response/main.py +++ b/tests/endtoend/blob_functions/get_blob_as_bytes_stream_return_http_response/main.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import json import hashlib +import json + import azure.functions as azf diff --git a/tests/endtoend/blob_functions/get_blob_as_str_return_http_response/main.py b/tests/endtoend/blob_functions/get_blob_as_str_return_http_response/main.py index 0e03f7d61..8d8bf5334 100644 --- a/tests/endtoend/blob_functions/get_blob_as_str_return_http_response/main.py +++ b/tests/endtoend/blob_functions/get_blob_as_str_return_http_response/main.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import json import hashlib +import json + import azure.functions as azf diff --git a/tests/endtoend/blob_functions/put_blob_as_bytes_return_http_response/main.py b/tests/endtoend/blob_functions/put_blob_as_bytes_return_http_response/main.py index e6e7109a7..5e461cf9f 100644 --- a/tests/endtoend/blob_functions/put_blob_as_bytes_return_http_response/main.py +++ b/tests/endtoend/blob_functions/put_blob_as_bytes_return_http_response/main.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import random -import json import hashlib +import json +import random + import azure.functions as azf diff --git a/tests/endtoend/blob_functions/put_blob_as_str_return_http_response/main.py b/tests/endtoend/blob_functions/put_blob_as_str_return_http_response/main.py index 901a7f3f1..4e16c84ad 100644 --- a/tests/endtoend/blob_functions/put_blob_as_str_return_http_response/main.py +++ b/tests/endtoend/blob_functions/put_blob_as_str_return_http_response/main.py @@ -1,10 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import string -import random -import json import hashlib +import json +import random +import string + import azure.functions as azf diff --git a/tests/endtoend/blob_functions/put_get_multiple_blobs_as_bytes_return_http_response/main.py b/tests/endtoend/blob_functions/put_get_multiple_blobs_as_bytes_return_http_response/main.py index abb87fbe1..9d2811e37 100644 --- a/tests/endtoend/blob_functions/put_get_multiple_blobs_as_bytes_return_http_response/main.py +++ b/tests/endtoend/blob_functions/put_get_multiple_blobs_as_bytes_return_http_response/main.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import random -import json import hashlib +import json +import random + import azure.functions as azf diff --git a/tests/endtoend/blueprint_functions/functions_in_both_blueprint_functionapp/function_app.py b/tests/endtoend/blueprint_functions/functions_in_both_blueprint_functionapp/function_app.py index 036467850..1813e0578 100644 --- a/tests/endtoend/blueprint_functions/functions_in_both_blueprint_functionapp/function_app.py +++ b/tests/endtoend/blueprint_functions/functions_in_both_blueprint_functionapp/function_app.py @@ -1,5 +1,4 @@ import azure.functions as func - from blueprint import bp app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/__init__.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/__init__.py index 4ed3cc550..88cb6b2dc 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/__init__.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/__init__.py @@ -1,14 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from ._abc import Context, Out -from ._http import HttpRequest -from ._http import HttpResponse -from .meta import get_binding_registry - # Import binding implementations to register them from . import http # NoQA - +from ._abc import Context, Out +from ._http import HttpRequest, HttpResponse +from .meta import get_binding_registry __all__ = ( # Functions diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_abc.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_abc.py index 40329ae00..8add53c99 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_abc.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_abc.py @@ -6,7 +6,6 @@ import io import typing - T = typing.TypeVar('T') diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_http.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_http.py index 748efa24b..89ee2678c 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_http.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_http.py @@ -4,11 +4,10 @@ import collections.abc import io import json -import typing import types +import typing from . import _abc - from ._thirdparty.werkzeug import datastructures as _wk_datastructures from ._thirdparty.werkzeug import formparser as _wk_parser from ._thirdparty.werkzeug import http as _wk_http diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_utils.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_utils.py index ebfe82ab9..a1bd9f3b8 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_utils.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/_utils.py @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from typing import List, Tuple, Optional from datetime import datetime, timedelta +from typing import List, Optional, Tuple def try_parse_datetime_with_formats( diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/meta.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/meta.py index 3e597185f..3dcff6da8 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/meta.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_newer_version/lib/site-packages/azure/functions/meta.py @@ -6,13 +6,10 @@ import datetime import json import re -from typing import Dict, Optional, Union, Tuple, Mapping, Any +from typing import Any, Dict, Mapping, Optional, Tuple, Union from ._thirdparty import typing_inspect -from ._utils import ( - try_parse_datetime_with_formats, - try_parse_timedelta_with_formats -) +from ._utils import try_parse_datetime_with_formats, try_parse_timedelta_with_formats def is_iterable_type_annotation(annotation: object, pytype: object) -> bool: diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/__init__.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/__init__.py index e9b437638..36953c55b 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/__init__.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/__init__.py @@ -1,14 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from ._abc import Context, Out -from ._http import HttpRequest -from ._http import HttpResponse -from .meta import get_binding_registry - # Import binding implementations to register them from . import http # NoQA - +from ._abc import Context, Out +from ._http import HttpRequest, HttpResponse +from .meta import get_binding_registry __all__ = ( # Functions diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_abc.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_abc.py index 40329ae00..8add53c99 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_abc.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_abc.py @@ -6,7 +6,6 @@ import io import typing - T = typing.TypeVar('T') diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_http.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_http.py index 748efa24b..89ee2678c 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_http.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_http.py @@ -4,11 +4,10 @@ import collections.abc import io import json -import typing import types +import typing from . import _abc - from ._thirdparty.werkzeug import datastructures as _wk_datastructures from ._thirdparty.werkzeug import formparser as _wk_parser from ._thirdparty.werkzeug import http as _wk_http diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_utils.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_utils.py index ebfe82ab9..a1bd9f3b8 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_utils.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/_utils.py @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from typing import List, Tuple, Optional from datetime import datetime, timedelta +from typing import List, Optional, Tuple def try_parse_datetime_with_formats( diff --git a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/meta.py b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/meta.py index 3e597185f..3dcff6da8 100644 --- a/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/meta.py +++ b/tests/endtoend/dependency_isolation_functions/.python_packages_azf_older_version/lib/site-packages/azure/functions/meta.py @@ -6,13 +6,10 @@ import datetime import json import re -from typing import Dict, Optional, Union, Tuple, Mapping, Any +from typing import Any, Dict, Mapping, Optional, Tuple, Union from ._thirdparty import typing_inspect -from ._utils import ( - try_parse_datetime_with_formats, - try_parse_timedelta_with_formats -) +from ._utils import try_parse_datetime_with_formats, try_parse_timedelta_with_formats def is_iterable_type_annotation(annotation: object, pytype: object) -> bool: diff --git a/tests/endtoend/dependency_isolation_functions/report_dependencies/__init__.py b/tests/endtoend/dependency_isolation_functions/report_dependencies/__init__.py index b4fe6d502..709fd6ca1 100644 --- a/tests/endtoend/dependency_isolation_functions/report_dependencies/__init__.py +++ b/tests/endtoend/dependency_isolation_functions/report_dependencies/__init__.py @@ -1,6 +1,7 @@ -import sys -import os import json +import os +import sys + import azure.functions as func import google.protobuf as proto import grpc diff --git a/tests/endtoend/durable_functions/DurableFunctionsHttpStart/__init__.py b/tests/endtoend/durable_functions/DurableFunctionsHttpStart/__init__.py index 27265bb5b..18709fccd 100644 --- a/tests/endtoend/durable_functions/DurableFunctionsHttpStart/__init__.py +++ b/tests/endtoend/durable_functions/DurableFunctionsHttpStart/__init__.py @@ -6,8 +6,8 @@ # - run pip install -r requirements.txt import logging -import azure.functions as func import azure.durable_functions as df +import azure.functions as func async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse: diff --git a/tests/endtoend/durable_functions/durable_functions_stein/function_app.py b/tests/endtoend/durable_functions/durable_functions_stein/function_app.py index 3ff137974..f0e95135b 100644 --- a/tests/endtoend/durable_functions/durable_functions_stein/function_app.py +++ b/tests/endtoend/durable_functions/durable_functions_stein/function_app.py @@ -1,7 +1,8 @@ -import azure.functions as func -import azure.durable_functions as df import logging +import azure.durable_functions as df +import azure.functions as func + app = df.DFApp() diff --git a/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/function_app.py b/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/function_app.py index d1fd116dc..94f05bf22 100644 --- a/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/function_app.py +++ b/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/function_app.py @@ -1,5 +1,6 @@ import json from datetime import datetime + import azure.functions as func from azure_functions_worker import logging diff --git a/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/generic/function_app.py b/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/generic/function_app.py index c02d4f71c..5dff24d80 100644 --- a/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/generic/function_app.py +++ b/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/generic/function_app.py @@ -1,5 +1,6 @@ import json from datetime import datetime + import azure.functions as func from azure_functions_worker import logging diff --git a/tests/endtoend/eventhub_batch_functions/eventhub_batch_functions_stein/function_app.py b/tests/endtoend/eventhub_batch_functions/eventhub_batch_functions_stein/function_app.py index 093d69228..0e4569132 100644 --- a/tests/endtoend/eventhub_batch_functions/eventhub_batch_functions_stein/function_app.py +++ b/tests/endtoend/eventhub_batch_functions/eventhub_batch_functions_stein/function_app.py @@ -3,8 +3,9 @@ import json import os import typing + import azure.functions as func -from azure.eventhub import EventHubProducerClient, EventData +from azure.eventhub import EventData, EventHubProducerClient app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/eventhub_batch_functions/metadata_multiple/__init__.py b/tests/endtoend/eventhub_batch_functions/metadata_multiple/__init__.py index 898a03c3d..3c9845d9f 100644 --- a/tests/endtoend/eventhub_batch_functions/metadata_multiple/__init__.py +++ b/tests/endtoend/eventhub_batch_functions/metadata_multiple/__init__.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import typing import json +import typing + import azure.functions as func diff --git a/tests/endtoend/eventhub_batch_functions/metadata_output_batch/__init__.py b/tests/endtoend/eventhub_batch_functions/metadata_output_batch/__init__.py index 88a50f3f3..54322c2af 100644 --- a/tests/endtoend/eventhub_batch_functions/metadata_output_batch/__init__.py +++ b/tests/endtoend/eventhub_batch_functions/metadata_output_batch/__init__.py @@ -1,11 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import os import json +import os import azure.functions as func -from azure.eventhub import EventHubProducerClient, EventData +from azure.eventhub import EventData, EventHubProducerClient # An HttpTrigger to generating EventHub event from azure-eventhub SDK. diff --git a/tests/endtoend/eventhub_functions/eventhub_functions_stein/function_app.py b/tests/endtoend/eventhub_functions/eventhub_functions_stein/function_app.py index 022a2009a..1091f8dd5 100644 --- a/tests/endtoend/eventhub_functions/eventhub_functions_stein/function_app.py +++ b/tests/endtoend/eventhub_functions/eventhub_functions_stein/function_app.py @@ -2,11 +2,10 @@ import os import typing +import azure.functions as func from azure.eventhub import EventData from azure.eventhub.aio import EventHubProducerClient -import azure.functions as func - app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/eventhub_functions/eventhub_functions_stein/generic/function_app.py b/tests/endtoend/eventhub_functions/eventhub_functions_stein/generic/function_app.py index 7b9f69891..1b2940488 100644 --- a/tests/endtoend/eventhub_functions/eventhub_functions_stein/generic/function_app.py +++ b/tests/endtoend/eventhub_functions/eventhub_functions_stein/generic/function_app.py @@ -2,11 +2,10 @@ import os import typing +import azure.functions as func from azure.eventhub import EventData from azure.eventhub.aio import EventHubProducerClient -import azure.functions as func - app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/eventhub_functions/metadata_output/__init__.py b/tests/endtoend/eventhub_functions/metadata_output/__init__.py index 5e7d32ebf..e02c79f13 100644 --- a/tests/endtoend/eventhub_functions/metadata_output/__init__.py +++ b/tests/endtoend/eventhub_functions/metadata_output/__init__.py @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import os import json +import os import azure.functions as func from azure.eventhub import EventData diff --git a/tests/endtoend/eventhub_functions/metadata_trigger/__init__.py b/tests/endtoend/eventhub_functions/metadata_trigger/__init__.py index 6a17c14b4..5088e6637 100644 --- a/tests/endtoend/eventhub_functions/metadata_trigger/__init__.py +++ b/tests/endtoend/eventhub_functions/metadata_trigger/__init__.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import typing import json +import typing + import azure.functions as func diff --git a/tests/endtoend/generic_functions/generic_functions_stein/function_app.py b/tests/endtoend/generic_functions/generic_functions_stein/function_app.py index c77aaaf03..654148c93 100644 --- a/tests/endtoend/generic_functions/generic_functions_stein/function_app.py +++ b/tests/endtoend/generic_functions/generic_functions_stein/function_app.py @@ -1,9 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import azure.functions as func - import logging +import azure.functions as func + app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/http_functions/common_libs_functions/common_libs_functions_stein/function_app.py b/tests/endtoend/http_functions/common_libs_functions/common_libs_functions_stein/function_app.py index 69d619816..e6174cae9 100644 --- a/tests/endtoend/http_functions/common_libs_functions/common_libs_functions_stein/function_app.py +++ b/tests/endtoend/http_functions/common_libs_functions/common_libs_functions_stein/function_app.py @@ -2,15 +2,15 @@ # Licensed under the MIT License. import logging + import azure.functions as func +import cv2 +import dotenv import numpy as np +import plotly import requests -import cv2 from pandas import DataFrame from sklearn.datasets import load_iris -import plotly -import dotenv - app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/http_functions/common_libs_functions/dotenv_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/dotenv_func/__init__.py index aaf3a753c..2046b551a 100644 --- a/tests/endtoend/http_functions/common_libs_functions/dotenv_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/dotenv_func/__init__.py @@ -2,8 +2,9 @@ # Licensed under the MIT License. import logging -import dotenv + import azure.functions as func +import dotenv def main(req: func.HttpRequest) -> func.HttpResponse: diff --git a/tests/endtoend/http_functions/common_libs_functions/numpy_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/numpy_func/__init__.py index 9b7ffa608..588ebb061 100644 --- a/tests/endtoend/http_functions/common_libs_functions/numpy_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/numpy_func/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import logging + import azure.functions as func import numpy as np diff --git a/tests/endtoend/http_functions/common_libs_functions/opencv_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/opencv_func/__init__.py index 8ba1d4364..e102878b9 100644 --- a/tests/endtoend/http_functions/common_libs_functions/opencv_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/opencv_func/__init__.py @@ -2,8 +2,9 @@ # Licensed under the MIT License. import logging -import cv2 + import azure.functions as func +import cv2 def main(req: func.HttpRequest) -> func.HttpResponse: diff --git a/tests/endtoend/http_functions/common_libs_functions/pandas_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/pandas_func/__init__.py index 7c36c90f5..4d6692015 100644 --- a/tests/endtoend/http_functions/common_libs_functions/pandas_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/pandas_func/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import logging + import azure.functions as func import numpy as np from pandas import DataFrame diff --git a/tests/endtoend/http_functions/common_libs_functions/plotly_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/plotly_func/__init__.py index 570902b40..4d93da913 100644 --- a/tests/endtoend/http_functions/common_libs_functions/plotly_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/plotly_func/__init__.py @@ -2,8 +2,9 @@ # Licensed under the MIT License. import logging -import plotly + import azure.functions as func +import plotly def main(req: func.HttpRequest) -> func.HttpResponse: diff --git a/tests/endtoend/http_functions/common_libs_functions/requests_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/requests_func/__init__.py index 48d8715d1..ffee90749 100644 --- a/tests/endtoend/http_functions/common_libs_functions/requests_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/requests_func/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import logging + import azure.functions as func import requests diff --git a/tests/endtoend/http_functions/common_libs_functions/sklearn_func/__init__.py b/tests/endtoend/http_functions/common_libs_functions/sklearn_func/__init__.py index 4ec8d35f1..578e925e8 100644 --- a/tests/endtoend/http_functions/common_libs_functions/sklearn_func/__init__.py +++ b/tests/endtoend/http_functions/common_libs_functions/sklearn_func/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import logging + import azure.functions as func from sklearn.datasets import load_iris diff --git a/tests/endtoend/http_functions/http_func/__init__.py b/tests/endtoend/http_functions/http_func/__init__.py index 6e8cb7118..0743efe9a 100644 --- a/tests/endtoend/http_functions/http_func/__init__.py +++ b/tests/endtoend/http_functions/http_func/__init__.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import time from datetime import datetime + # flake8: noqa import azure.functions as func -import time def main(req: func.HttpRequest) -> func.HttpResponse: diff --git a/tests/endtoend/http_functions/http_functions_stein/file_name/main.py b/tests/endtoend/http_functions/http_functions_stein/file_name/main.py index f5d4e1171..512cf83c2 100644 --- a/tests/endtoend/http_functions/http_functions_stein/file_name/main.py +++ b/tests/endtoend/http_functions/http_functions_stein/file_name/main.py @@ -1,9 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from datetime import datetime import logging import time +from datetime import datetime import azure.functions as func diff --git a/tests/endtoend/http_functions/http_functions_stein/function_app.py b/tests/endtoend/http_functions/http_functions_stein/function_app.py index 9662a92a1..f60697475 100644 --- a/tests/endtoend/http_functions/http_functions_stein/function_app.py +++ b/tests/endtoend/http_functions/http_functions_stein/function_app.py @@ -1,9 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from datetime import datetime import logging import time +from datetime import datetime import azure.functions as func diff --git a/tests/endtoend/http_functions/user_thread_logging/async_thread_pool_executor/__init__.py b/tests/endtoend/http_functions/user_thread_logging/async_thread_pool_executor/__init__.py index 32269bef3..3c124f4da 100644 --- a/tests/endtoend/http_functions/user_thread_logging/async_thread_pool_executor/__init__.py +++ b/tests/endtoend/http_functions/user_thread_logging/async_thread_pool_executor/__init__.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import concurrent.futures + # flake8: noqa import logging -import concurrent.futures import azure.functions as func diff --git a/tests/endtoend/http_functions/user_thread_logging/thread_pool_executor/__init__.py b/tests/endtoend/http_functions/user_thread_logging/thread_pool_executor/__init__.py index f2b6d536b..4ed94266e 100644 --- a/tests/endtoend/http_functions/user_thread_logging/thread_pool_executor/__init__.py +++ b/tests/endtoend/http_functions/user_thread_logging/thread_pool_executor/__init__.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import concurrent.futures + # flake8: noqa import logging -import concurrent.futures import azure.functions as func diff --git a/tests/endtoend/queue_functions/put_queue_return_multiple/main.py b/tests/endtoend/queue_functions/put_queue_return_multiple/main.py index a71f9e5b6..93152d7bb 100644 --- a/tests/endtoend/queue_functions/put_queue_return_multiple/main.py +++ b/tests/endtoend/queue_functions/put_queue_return_multiple/main.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import typing + import azure.functions as azf diff --git a/tests/endtoend/queue_functions/queue_trigger_return_multiple/main.py b/tests/endtoend/queue_functions/queue_trigger_return_multiple/main.py index c4e97554d..6abb82b0a 100644 --- a/tests/endtoend/queue_functions/queue_trigger_return_multiple/main.py +++ b/tests/endtoend/queue_functions/queue_trigger_return_multiple/main.py @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import logging -import azure.functions as azf +import azure.functions as azf logger = logging.getLogger(__name__) diff --git a/tests/endtoend/queue_functions/queue_trigger_untyped/main.py b/tests/endtoend/queue_functions/queue_trigger_untyped/main.py index 02779a8a3..64fa31587 100644 --- a/tests/endtoend/queue_functions/queue_trigger_untyped/main.py +++ b/tests/endtoend/queue_functions/queue_trigger_untyped/main.py @@ -2,7 +2,6 @@ # Licensed under the MIT License. import logging - logger = logging.getLogger(__name__) diff --git a/tests/endtoend/retry_policy_functions/exponential_strategy/function_app.py b/tests/endtoend/retry_policy_functions/exponential_strategy/function_app.py index 5370c8b6e..5180119ee 100644 --- a/tests/endtoend/retry_policy_functions/exponential_strategy/function_app.py +++ b/tests/endtoend/retry_policy_functions/exponential_strategy/function_app.py @@ -1,6 +1,7 @@ -from azure.functions import FunctionApp, TimerRequest, Context, AuthLevel import logging +from azure.functions import AuthLevel, Context, FunctionApp, TimerRequest + app = FunctionApp(http_auth_level=AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/retry_policy_functions/fixed_strategy/function_app.py b/tests/endtoend/retry_policy_functions/fixed_strategy/function_app.py index 5d72fd181..1f5863f47 100644 --- a/tests/endtoend/retry_policy_functions/fixed_strategy/function_app.py +++ b/tests/endtoend/retry_policy_functions/fixed_strategy/function_app.py @@ -1,6 +1,7 @@ -from azure.functions import FunctionApp, TimerRequest, Context, AuthLevel import logging +from azure.functions import AuthLevel, Context, FunctionApp, TimerRequest + app = FunctionApp(http_auth_level=AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/sql_functions/sql_functions_stein/function_app.py b/tests/endtoend/sql_functions/sql_functions_stein/function_app.py index 81eab7067..07c78c385 100644 --- a/tests/endtoend/sql_functions/sql_functions_stein/function_app.py +++ b/tests/endtoend/sql_functions/sql_functions_stein/function_app.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import azure.functions as func import json +import azure.functions as func + app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/sql_functions/sql_functions_stein/generic/function_app.py b/tests/endtoend/sql_functions/sql_functions_stein/generic/function_app.py index 45c7c2e37..2e796f8bb 100644 --- a/tests/endtoend/sql_functions/sql_functions_stein/generic/function_app.py +++ b/tests/endtoend/sql_functions/sql_functions_stein/generic/function_app.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import azure.functions as func import json +import azure.functions as func + app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/sql_functions/sql_input/__init__.py b/tests/endtoend/sql_functions/sql_input/__init__.py index a8e3c3b3b..03c622492 100644 --- a/tests/endtoend/sql_functions/sql_input/__init__.py +++ b/tests/endtoend/sql_functions/sql_input/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import json + import azure.functions as func diff --git a/tests/endtoend/sql_functions/sql_input2/__init__.py b/tests/endtoend/sql_functions/sql_input2/__init__.py index a8e3c3b3b..03c622492 100644 --- a/tests/endtoend/sql_functions/sql_input2/__init__.py +++ b/tests/endtoend/sql_functions/sql_input2/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import json + import azure.functions as func diff --git a/tests/endtoend/sql_functions/sql_output/__init__.py b/tests/endtoend/sql_functions/sql_output/__init__.py index 1a8226b51..42a21ff24 100644 --- a/tests/endtoend/sql_functions/sql_output/__init__.py +++ b/tests/endtoend/sql_functions/sql_output/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import json + import azure.functions as func diff --git a/tests/endtoend/sql_functions/sql_trigger/__init__.py b/tests/endtoend/sql_functions/sql_trigger/__init__.py index c8e18173e..56115c75d 100644 --- a/tests/endtoend/sql_functions/sql_trigger/__init__.py +++ b/tests/endtoend/sql_functions/sql_trigger/__init__.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json + import azure.functions as func diff --git a/tests/endtoend/table_functions/table_functions_stein/function_app.py b/tests/endtoend/table_functions/table_functions_stein/function_app.py index 4b5b11d68..5ebd10e07 100644 --- a/tests/endtoend/table_functions/table_functions_stein/function_app.py +++ b/tests/endtoend/table_functions/table_functions_stein/function_app.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import json import uuid + import azure.functions as func app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/table_functions/table_functions_stein/generic/function_app.py b/tests/endtoend/table_functions/table_functions_stein/generic/function_app.py index 4b8ef0e09..0a03a2366 100644 --- a/tests/endtoend/table_functions/table_functions_stein/generic/function_app.py +++ b/tests/endtoend/table_functions/table_functions_stein/generic/function_app.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import json import uuid + import azure.functions as func app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/endtoend/test_blob_functions.py b/tests/endtoend/test_blob_functions.py index 795555b4d..4d51693e9 100644 --- a/tests/endtoend/test_blob_functions.py +++ b/tests/endtoend/test_blob_functions.py @@ -3,7 +3,6 @@ import time from requests import JSONDecodeError - from tests.utils import testutils diff --git a/tests/endtoend/test_dependency_isolation_functions.py b/tests/endtoend/test_dependency_isolation_functions.py index c1b918072..ec1cc251f 100644 --- a/tests/endtoend/test_dependency_isolation_functions.py +++ b/tests/endtoend/test_dependency_isolation_functions.py @@ -7,11 +7,14 @@ from unittest.mock import patch from requests import Response +from tests.utils import testutils +from tests.utils.constants import ( + CONSUMPTION_DOCKER_TEST, + DEDICATED_DOCKER_TEST, + PYAZURE_INTEGRATION_TEST, +) from azure_functions_worker.utils.common import is_envvar_true -from tests.utils import testutils -from tests.utils.constants import PYAZURE_INTEGRATION_TEST, \ - CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST REQUEST_TIMEOUT_SEC = 5 diff --git a/tests/endtoend/test_durable_functions.py b/tests/endtoend/test_durable_functions.py index 160723f95..8cab19b6f 100644 --- a/tests/endtoend/test_durable_functions.py +++ b/tests/endtoend/test_durable_functions.py @@ -6,10 +6,10 @@ from unittest import skipIf import requests +from tests.utils import testutils +from tests.utils.constants import CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST from azure_functions_worker.utils.common import is_envvar_true -from tests.utils import testutils -from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST @skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) diff --git a/tests/endtoend/test_eventgrid_functions.py b/tests/endtoend/test_eventgrid_functions.py index 1bc4831e0..7a878ca32 100644 --- a/tests/endtoend/test_eventgrid_functions.py +++ b/tests/endtoend/test_eventgrid_functions.py @@ -5,7 +5,6 @@ import uuid import requests - from tests.utils import testutils diff --git a/tests/endtoend/test_eventhub_batch_functions.py b/tests/endtoend/test_eventhub_batch_functions.py index 5a1c89073..5785de398 100644 --- a/tests/endtoend/test_eventhub_batch_functions.py +++ b/tests/endtoend/test_eventhub_batch_functions.py @@ -6,10 +6,10 @@ from unittest import skipIf from dateutil import parser +from tests.utils import testutils +from tests.utils.constants import CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST from azure_functions_worker.utils.common import is_envvar_true -from tests.utils import testutils -from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST @skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) diff --git a/tests/endtoend/test_file_name_functions.py b/tests/endtoend/test_file_name_functions.py index 0e74851b2..faf3b722f 100644 --- a/tests/endtoend/test_file_name_functions.py +++ b/tests/endtoend/test_file_name_functions.py @@ -1,10 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os + import requests +from tests.utils import testutils from azure_functions_worker.constants import PYTHON_SCRIPT_FILE_NAME -from tests.utils import testutils REQUEST_TIMEOUT_SEC = 10 diff --git a/tests/endtoend/test_generic_functions.py b/tests/endtoend/test_generic_functions.py index fa983a060..46f839377 100644 --- a/tests/endtoend/test_generic_functions.py +++ b/tests/endtoend/test_generic_functions.py @@ -1,13 +1,13 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from unittest import skipIf - import time import typing +from unittest import skipIf -from azure_functions_worker.utils.common import is_envvar_true from tests.utils import testutils -from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST +from tests.utils.constants import CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST + +from azure_functions_worker.utils.common import is_envvar_true @skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) diff --git a/tests/endtoend/test_http_functions.py b/tests/endtoend/test_http_functions.py index 2213e0c79..3128dfd38 100644 --- a/tests/endtoend/test_http_functions.py +++ b/tests/endtoend/test_http_functions.py @@ -5,9 +5,9 @@ from unittest.mock import patch import requests +from tests.utils import testutils from azure_functions_worker.constants import PYTHON_ENABLE_INIT_INDEXING -from tests.utils import testutils REQUEST_TIMEOUT_SEC = 5 diff --git a/tests/endtoend/test_servicebus_functions.py b/tests/endtoend/test_servicebus_functions.py index 34f51c5bc..c8b691579 100644 --- a/tests/endtoend/test_servicebus_functions.py +++ b/tests/endtoend/test_servicebus_functions.py @@ -4,9 +4,10 @@ import time from unittest import skipIf -from azure_functions_worker.utils.common import is_envvar_true from tests.utils import testutils -from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST +from tests.utils.constants import CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST + +from azure_functions_worker.utils.common import is_envvar_true @skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) diff --git a/tests/endtoend/test_table_functions.py b/tests/endtoend/test_table_functions.py index 0c7ff3b90..c53d6e8d6 100644 --- a/tests/endtoend/test_table_functions.py +++ b/tests/endtoend/test_table_functions.py @@ -5,10 +5,10 @@ import time from unittest import skipIf -from azure_functions_worker.utils.common import is_envvar_true from tests.utils import testutils -from tests.utils.constants import DEDICATED_DOCKER_TEST, \ - CONSUMPTION_DOCKER_TEST +from tests.utils.constants import CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST + +from azure_functions_worker.utils.common import is_envvar_true @skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) diff --git a/tests/endtoend/test_third_party_http_functions.py b/tests/endtoend/test_third_party_http_functions.py index 8f6b555a9..5fa01a2bd 100644 --- a/tests/endtoend/test_third_party_http_functions.py +++ b/tests/endtoend/test_third_party_http_functions.py @@ -3,7 +3,6 @@ import os import requests - from tests.utils import testutils as utils from tests.utils.testutils import E2E_TESTS_ROOT diff --git a/tests/endtoend/test_threadpool_thread_count_functions.py b/tests/endtoend/test_threadpool_thread_count_functions.py index d1b73a69a..2388aae9c 100644 --- a/tests/endtoend/test_threadpool_thread_count_functions.py +++ b/tests/endtoend/test_threadpool_thread_count_functions.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os -from threading import Thread from datetime import datetime +from threading import Thread + from tests.utils import testutils diff --git a/tests/endtoend/test_timer_functions.py b/tests/endtoend/test_timer_functions.py index 12055bc6c..7923637bd 100644 --- a/tests/endtoend/test_timer_functions.py +++ b/tests/endtoend/test_timer_functions.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import time import typing + from tests.utils import testutils REQUEST_TIMEOUT_SEC = 5 diff --git a/tests/endtoend/test_warmup_functions.py b/tests/endtoend/test_warmup_functions.py index 63905451a..b33eee26f 100644 --- a/tests/endtoend/test_warmup_functions.py +++ b/tests/endtoend/test_warmup_functions.py @@ -4,9 +4,10 @@ import typing from unittest import skipIf -from azure_functions_worker.utils.common import is_envvar_true from tests.utils import testutils -from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST +from tests.utils.constants import CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST + +from azure_functions_worker.utils.common import is_envvar_true @skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) diff --git a/tests/endtoend/test_worker_process_count_functions.py b/tests/endtoend/test_worker_process_count_functions.py index e3cd3df60..8ee6577bc 100644 --- a/tests/endtoend/test_worker_process_count_functions.py +++ b/tests/endtoend/test_worker_process_count_functions.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os -from threading import Thread from datetime import datetime +from threading import Thread + from tests.utils import testutils diff --git a/tests/endtoend/third_party_http_functions/stein/asgi_function/function_app.py b/tests/endtoend/third_party_http_functions/stein/asgi_function/function_app.py index c5570be68..391d036c0 100644 --- a/tests/endtoend/third_party_http_functions/stein/asgi_function/function_app.py +++ b/tests/endtoend/third_party_http_functions/stein/asgi_function/function_app.py @@ -1,7 +1,7 @@ from typing import Optional import azure.functions as func -from fastapi import FastAPI, Response, Body, HTTPException +from fastapi import Body, FastAPI, HTTPException, Response from pydantic import BaseModel fast_app = FastAPI() diff --git a/tests/endtoend/warmup_functions/warmup_functions_stein/function_app.py b/tests/endtoend/warmup_functions/warmup_functions_stein/function_app.py index 371820976..83968cc4d 100644 --- a/tests/endtoend/warmup_functions/warmup_functions_stein/function_app.py +++ b/tests/endtoend/warmup_functions/warmup_functions_stein/function_app.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import azure.functions as func import logging +import azure.functions as func + app = func.FunctionApp() diff --git a/tests/extension_tests/deferred_bindings_tests/deferred_bindings_functions/deferred_bindings_disabled/function_app.py b/tests/extension_tests/deferred_bindings_tests/deferred_bindings_functions/deferred_bindings_disabled/function_app.py index 19034479b..9ec066bcb 100644 --- a/tests/extension_tests/deferred_bindings_tests/deferred_bindings_functions/deferred_bindings_disabled/function_app.py +++ b/tests/extension_tests/deferred_bindings_tests/deferred_bindings_functions/deferred_bindings_disabled/function_app.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json + import azure.functions as func app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings.py b/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings.py index ab614a55c..bdba53a8e 100644 --- a/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings.py +++ b/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings.py @@ -1,13 +1,13 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import unittest import sys +import unittest import azure.functions as func +from tests.utils import testutils from azure_functions_worker import protos from azure_functions_worker.bindings import datumdef, meta -from tests.utils import testutils # Even if the tests are skipped for <=3.8, the library is still imported as # it is used for these tests. diff --git a/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py b/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py index da60861f9..0a90f2075 100644 --- a/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py +++ b/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py @@ -1,10 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import sys import time import unittest -import sys from tests.utils import testutils + from azure_functions_worker.bindings import meta diff --git a/tests/extension_tests/http_v2_tests/http_functions_v2/fastapi/function_app.py b/tests/extension_tests/http_v2_tests/http_functions_v2/fastapi/function_app.py index 355de98a8..b20f5440c 100644 --- a/tests/extension_tests/http_v2_tests/http_functions_v2/fastapi/function_app.py +++ b/tests/extension_tests/http_v2_tests/http_functions_v2/fastapi/function_app.py @@ -1,13 +1,19 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from datetime import datetime import logging import time +from datetime import datetime import azure.functions as func -from azurefunctions.extensions.http.fastapi import Request, Response, \ - StreamingResponse, HTMLResponse, \ - UJSONResponse, ORJSONResponse, FileResponse +from azurefunctions.extensions.http.fastapi import ( + FileResponse, + HTMLResponse, + ORJSONResponse, + Request, + Response, + StreamingResponse, + UJSONResponse, +) app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/extension_tests/http_v2_tests/test_http_v2.py b/tests/extension_tests/http_v2_tests/test_http_v2.py index 022ffa972..8409b7e58 100644 --- a/tests/extension_tests/http_v2_tests/test_http_v2.py +++ b/tests/extension_tests/http_v2_tests/test_http_v2.py @@ -7,9 +7,9 @@ from concurrent.futures import ThreadPoolExecutor import requests +from tests.utils import testutils from azure_functions_worker.constants import PYTHON_ENABLE_INIT_INDEXING -from tests.utils import testutils REQUEST_TIMEOUT_SEC = 5 diff --git a/tests/unittests/azure_namespace_import/azure_namespace_import.py b/tests/unittests/azure_namespace_import/azure_namespace_import.py index 0bed9349b..a7490cf50 100644 --- a/tests/unittests/azure_namespace_import/azure_namespace_import.py +++ b/tests/unittests/azure_namespace_import/azure_namespace_import.py @@ -1,12 +1,13 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import asyncio import os -import sys import shutil -import asyncio +import sys from azure_functions_worker import protos -from ...utils.testutils import create_dummy_dispatcher, UNIT_TESTS_ROOT + +from ...utils.testutils import UNIT_TESTS_ROOT, create_dummy_dispatcher async def verify_nested_namespace_import(): diff --git a/tests/unittests/broken_functions/missing_module/main.py b/tests/unittests/broken_functions/missing_module/main.py index 65f4261a3..16e9e5d5f 100644 --- a/tests/unittests/broken_functions/missing_module/main.py +++ b/tests/unittests/broken_functions/missing_module/main.py @@ -5,7 +5,6 @@ import azure.functions import does_not_exist # Noqa - logger = logging.getLogger('my function') diff --git a/tests/unittests/dispatcher_functions/http_v2/fastapi/function_app.py b/tests/unittests/dispatcher_functions/http_v2/fastapi/function_app.py index a2c15d419..8a8982349 100644 --- a/tests/unittests/dispatcher_functions/http_v2/fastapi/function_app.py +++ b/tests/unittests/dispatcher_functions/http_v2/fastapi/function_app.py @@ -1,6 +1,5 @@ -from azurefunctions.extensions.http.fastapi import Request, Response import azure.functions as func - +from azurefunctions.extensions.http.fastapi import Request, Response app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/unittests/dispatcher_functions/show_context/__init__.py b/tests/unittests/dispatcher_functions/show_context/__init__.py index 17755a716..31f9766f9 100644 --- a/tests/unittests/dispatcher_functions/show_context/__init__.py +++ b/tests/unittests/dispatcher_functions/show_context/__init__.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json + import azure.functions as func diff --git a/tests/unittests/dispatcher_functions/show_context_async/__init__.py b/tests/unittests/dispatcher_functions/show_context_async/__init__.py index da61ce16c..e43e8fa7d 100644 --- a/tests/unittests/dispatcher_functions/show_context_async/__init__.py +++ b/tests/unittests/dispatcher_functions/show_context_async/__init__.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json + import azure.functions as func diff --git a/tests/unittests/eventhub_mock_functions/eventhub_cardinality_many/__init__.py b/tests/unittests/eventhub_mock_functions/eventhub_cardinality_many/__init__.py index b2a0ea621..eb75a0012 100644 --- a/tests/unittests/eventhub_mock_functions/eventhub_cardinality_many/__init__.py +++ b/tests/unittests/eventhub_mock_functions/eventhub_cardinality_many/__init__.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from typing import List + import azure.functions as func diff --git a/tests/unittests/http_functions/async_logging/main.py b/tests/unittests/http_functions/async_logging/main.py index 9f779cee9..e30b88660 100644 --- a/tests/unittests/http_functions/async_logging/main.py +++ b/tests/unittests/http_functions/async_logging/main.py @@ -5,7 +5,6 @@ import azure.functions - logger = logging.getLogger('my function') diff --git a/tests/unittests/http_functions/async_return_str/main.py b/tests/unittests/http_functions/async_return_str/main.py index 4a540ba05..a64f811f7 100644 --- a/tests/unittests/http_functions/async_return_str/main.py +++ b/tests/unittests/http_functions/async_return_str/main.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import asyncio + import azure.functions diff --git a/tests/unittests/http_functions/hijack_current_event_loop/main.py b/tests/unittests/http_functions/hijack_current_event_loop/main.py index 4f48b85ba..10856ca46 100644 --- a/tests/unittests/http_functions/hijack_current_event_loop/main.py +++ b/tests/unittests/http_functions/hijack_current_event_loop/main.py @@ -1,12 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import sys -import logging import asyncio +import logging +import sys import azure.functions as func - logger = logging.getLogger('custom_logger') # Attempt to log info into system log from customer code diff --git a/tests/unittests/http_functions/http_v2_functions/fastapi/function_app.py b/tests/unittests/http_functions/http_v2_functions/fastapi/function_app.py index b4018466d..c10bcb8ec 100644 --- a/tests/unittests/http_functions/http_v2_functions/fastapi/function_app.py +++ b/tests/unittests/http_functions/http_v2_functions/fastapi/function_app.py @@ -6,9 +6,14 @@ import sys import time from urllib.request import urlopen -from azurefunctions.extensions.http.fastapi import Request, Response, \ - HTMLResponse, RedirectResponse + import azure.functions as func +from azurefunctions.extensions.http.fastapi import ( + HTMLResponse, + RedirectResponse, + Request, + Response, +) from pydantic import BaseModel app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) diff --git a/tests/unittests/http_functions/no_return/main.py b/tests/unittests/http_functions/no_return/main.py index 87101bc6f..1e9c228fc 100644 --- a/tests/unittests/http_functions/no_return/main.py +++ b/tests/unittests/http_functions/no_return/main.py @@ -2,7 +2,6 @@ # Licensed under the MIT License. import logging - logger = logging.getLogger('test') diff --git a/tests/unittests/http_functions/print_logging/main.py b/tests/unittests/http_functions/print_logging/main.py index 084e24f35..87fd693f6 100644 --- a/tests/unittests/http_functions/print_logging/main.py +++ b/tests/unittests/http_functions/print_logging/main.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import sys + import azure.functions diff --git a/tests/unittests/http_functions/return_request/main.py b/tests/unittests/http_functions/return_request/main.py index ca3e0b669..842e18581 100644 --- a/tests/unittests/http_functions/return_request/main.py +++ b/tests/unittests/http_functions/return_request/main.py @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import json import hashlib +import json import azure.functions diff --git a/tests/unittests/http_functions/return_route_params/main.py b/tests/unittests/http_functions/return_route_params/main.py index 8cbecc963..1cc7f0740 100644 --- a/tests/unittests/http_functions/return_route_params/main.py +++ b/tests/unittests/http_functions/return_route_params/main.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json + import azure.functions diff --git a/tests/unittests/http_functions/sync_logging/main.py b/tests/unittests/http_functions/sync_logging/main.py index 71460bc26..9b4d89634 100644 --- a/tests/unittests/http_functions/sync_logging/main.py +++ b/tests/unittests/http_functions/sync_logging/main.py @@ -5,7 +5,6 @@ import azure.functions - logger = logging.getLogger('my function') diff --git a/tests/unittests/http_functions/user_event_loop/main.py b/tests/unittests/http_functions/user_event_loop/main.py index c655ad6c5..879b1cf86 100644 --- a/tests/unittests/http_functions/user_event_loop/main.py +++ b/tests/unittests/http_functions/user_event_loop/main.py @@ -1,11 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import logging import asyncio +import logging import azure.functions as func - logger = logging.getLogger('my function') diff --git a/tests/unittests/load_functions/load_outside_main/main.py b/tests/unittests/load_functions/load_outside_main/main.py index 5964719dd..9c8dea18c 100644 --- a/tests/unittests/load_functions/load_outside_main/main.py +++ b/tests/unittests/load_functions/load_outside_main/main.py @@ -7,16 +7,19 @@ def main(req: func.HttpRequest): if req.params['from'] == 'init': # Ensure the module can still be loaded from package.__init__ - from ..stub_http_trigger.__init__ import main # NoQA from __app__.stub_http_trigger.__init__ import main # NoQA + from ..stub_http_trigger.__init__ import main # NoQA + elif req.params['from'] == 'package': # Ensure the module can still be loaded from package - from ..stub_http_trigger import main from __app__.stub_http_trigger import main # NoQA + from ..stub_http_trigger import main + # Ensure submodules can also be imported - from ..stub_http_trigger.stub_tools import FOO # NoQA from __app__.stub_http_trigger.stub_tools import FOO # NoQA + from ..stub_http_trigger.stub_tools import FOO # NoQA + return 'OK' diff --git a/tests/unittests/load_functions/outside_main_code_in_init/__init__.py b/tests/unittests/load_functions/outside_main_code_in_init/__init__.py index dac451ef5..d1046410c 100644 --- a/tests/unittests/load_functions/outside_main_code_in_init/__init__.py +++ b/tests/unittests/load_functions/outside_main_code_in_init/__init__.py @@ -1,8 +1,7 @@ # This function app is to ensure the code outside main() function # should only get loaded once in __init__.py -from .count import invoke, get_invoke_count, reset_count - +from .count import get_invoke_count, invoke, reset_count invoke() diff --git a/tests/unittests/load_functions/outside_main_code_in_main/main.py b/tests/unittests/load_functions/outside_main_code_in_main/main.py index dac451ef5..d1046410c 100644 --- a/tests/unittests/load_functions/outside_main_code_in_main/main.py +++ b/tests/unittests/load_functions/outside_main_code_in_main/main.py @@ -1,8 +1,7 @@ # This function app is to ensure the code outside main() function # should only get loaded once in __init__.py -from .count import invoke, get_invoke_count, reset_count - +from .count import get_invoke_count, invoke, reset_count invoke() diff --git a/tests/unittests/log_filtering_functions/debug_user_logging/main.py b/tests/unittests/log_filtering_functions/debug_user_logging/main.py index 6cf0465af..1f669b236 100644 --- a/tests/unittests/log_filtering_functions/debug_user_logging/main.py +++ b/tests/unittests/log_filtering_functions/debug_user_logging/main.py @@ -4,7 +4,6 @@ import azure.functions - logger = logging.getLogger('my function') diff --git a/tests/unittests/log_filtering_functions/sdk_logging/__init__.py b/tests/unittests/log_filtering_functions/sdk_logging/__init__.py index a30221e2b..b45da85a5 100644 --- a/tests/unittests/log_filtering_functions/sdk_logging/__init__.py +++ b/tests/unittests/log_filtering_functions/sdk_logging/__init__.py @@ -4,7 +4,6 @@ import azure.functions as func - sdk_logger = logging.getLogger('azure.functions') diff --git a/tests/unittests/log_filtering_functions/sdk_submodule_logging/__init__.py b/tests/unittests/log_filtering_functions/sdk_submodule_logging/__init__.py index acdef9e10..5950d0432 100644 --- a/tests/unittests/log_filtering_functions/sdk_submodule_logging/__init__.py +++ b/tests/unittests/log_filtering_functions/sdk_submodule_logging/__init__.py @@ -4,7 +4,6 @@ import azure.functions as func - sdk_submodule_logger = logging.getLogger('azure.functions.submodule') diff --git a/tests/unittests/path_import/path_import.py b/tests/unittests/path_import/path_import.py index 08efc26a3..bc22de775 100644 --- a/tests/unittests/path_import/path_import.py +++ b/tests/unittests/path_import/path_import.py @@ -1,13 +1,14 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import asyncio import os -import sys import shutil -import asyncio +import sys -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + async def verify_path_imports(): test_env = {} diff --git a/tests/unittests/resources/customer_deps_path/azure/functions/__init__.py b/tests/unittests/resources/customer_deps_path/azure/functions/__init__.py index 420f1d1b0..e5e3779b1 100644 --- a/tests/unittests/resources/customer_deps_path/azure/functions/__init__.py +++ b/tests/unittests/resources/customer_deps_path/azure/functions/__init__.py @@ -4,5 +4,6 @@ __version__: str = 'customer' import os + # ./tests/unittests/resources/customer_deps_path/common_module package_location: str = os.path.dirname(__file__) diff --git a/tests/unittests/resources/customer_deps_path/common_module/__init__.py b/tests/unittests/resources/customer_deps_path/common_module/__init__.py index 420f1d1b0..e5e3779b1 100644 --- a/tests/unittests/resources/customer_deps_path/common_module/__init__.py +++ b/tests/unittests/resources/customer_deps_path/common_module/__init__.py @@ -4,5 +4,6 @@ __version__: str = 'customer' import os + # ./tests/unittests/resources/customer_deps_path/common_module package_location: str = os.path.dirname(__file__) diff --git a/tests/unittests/resources/customer_deps_path/common_namespace/nested_module/__init__.py b/tests/unittests/resources/customer_deps_path/common_namespace/nested_module/__init__.py index 5c9f7e2d2..07afaec18 100644 --- a/tests/unittests/resources/customer_deps_path/common_namespace/nested_module/__init__.py +++ b/tests/unittests/resources/customer_deps_path/common_namespace/nested_module/__init__.py @@ -4,5 +4,6 @@ __version__: str = 'customer' import os + # ./tests/unittests/resources/customer_deps_path/common_namespace/nested_module package_location: str = os.path.dirname(__file__) diff --git a/tests/unittests/resources/customer_func_path/HttpTrigger/__init__.py b/tests/unittests/resources/customer_func_path/HttpTrigger/__init__.py index 34451943f..d5d57e3eb 100644 --- a/tests/unittests/resources/customer_func_path/HttpTrigger/__init__.py +++ b/tests/unittests/resources/customer_func_path/HttpTrigger/__init__.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import os + import azure.functions as func # NoQA diff --git a/tests/unittests/resources/customer_func_path/common_module/__init__.py b/tests/unittests/resources/customer_func_path/common_module/__init__.py index 8a7910ea4..0784c9b6f 100644 --- a/tests/unittests/resources/customer_func_path/common_module/__init__.py +++ b/tests/unittests/resources/customer_func_path/common_module/__init__.py @@ -2,7 +2,6 @@ # Licensed under the MIT License. import os - FUNCTION_APP = "function_app" __version__: str == FUNCTION_APP diff --git a/tests/unittests/resources/customer_func_path/func_specific_module/__init__.py b/tests/unittests/resources/customer_func_path/func_specific_module/__init__.py index a14ee353f..ed832cbbc 100644 --- a/tests/unittests/resources/customer_func_path/func_specific_module/__init__.py +++ b/tests/unittests/resources/customer_func_path/func_specific_module/__init__.py @@ -2,7 +2,6 @@ # Licensed under the MIT License. import os - FUNCTION_APP = "function_app" __version__: str == FUNCTION_APP diff --git a/tests/unittests/resources/worker_deps_path/azure/functions/__init__.py b/tests/unittests/resources/worker_deps_path/azure/functions/__init__.py index 1323479ec..abdc27afc 100644 --- a/tests/unittests/resources/worker_deps_path/azure/functions/__init__.py +++ b/tests/unittests/resources/worker_deps_path/azure/functions/__init__.py @@ -4,5 +4,6 @@ __version__: str = 'worker' import os + # ./tests/unittests/resources/worker_deps_path/common_module package_location: str = os.path.dirname(__file__) diff --git a/tests/unittests/resources/worker_deps_path/common_module/__init__.py b/tests/unittests/resources/worker_deps_path/common_module/__init__.py index 1323479ec..abdc27afc 100644 --- a/tests/unittests/resources/worker_deps_path/common_module/__init__.py +++ b/tests/unittests/resources/worker_deps_path/common_module/__init__.py @@ -4,5 +4,6 @@ __version__: str = 'worker' import os + # ./tests/unittests/resources/worker_deps_path/common_module package_location: str = os.path.dirname(__file__) diff --git a/tests/unittests/resources/worker_deps_path/common_namespace/nested_module/__init__.py b/tests/unittests/resources/worker_deps_path/common_namespace/nested_module/__init__.py index b984101a8..3211c9534 100644 --- a/tests/unittests/resources/worker_deps_path/common_namespace/nested_module/__init__.py +++ b/tests/unittests/resources/worker_deps_path/common_namespace/nested_module/__init__.py @@ -4,5 +4,6 @@ __version__: str = 'worker' import os + # ./tests/unittests/resources/worker_deps_path/common_namespace/nested_module package_location: str = os.path.dirname(__file__) diff --git a/tests/unittests/test-binding/setup.py b/tests/unittests/test-binding/setup.py index dc9ee9fda..e0e248693 100644 --- a/tests/unittests/test-binding/setup.py +++ b/tests/unittests/test-binding/setup.py @@ -2,7 +2,6 @@ # Licensed under the MIT License. from setuptools import setup - setup( name='foo-binding', version='1.0', diff --git a/tests/unittests/test_app_setting_manager.py b/tests/unittests/test_app_setting_manager.py index ff9c5b526..d203704f9 100644 --- a/tests/unittests/test_app_setting_manager.py +++ b/tests/unittests/test_app_setting_manager.py @@ -2,14 +2,16 @@ # Licensed under the MIT License. import collections as col import os - from unittest.mock import patch from tests.utils import testutils -from azure_functions_worker.utils.app_setting_manager import \ - get_python_appsetting_state -from azure_functions_worker.constants import PYTHON_THREADPOOL_THREAD_COUNT, \ - PYTHON_ENABLE_DEBUG_LOGGING, PYTHON_ENABLE_INIT_INDEXING + +from azure_functions_worker.constants import ( + PYTHON_ENABLE_DEBUG_LOGGING, + PYTHON_ENABLE_INIT_INDEXING, + PYTHON_THREADPOOL_THREAD_COUNT, +) +from azure_functions_worker.utils.app_setting_manager import get_python_appsetting_state SysVersionInfo = col.namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]) diff --git a/tests/unittests/test_broken_functions.py b/tests/unittests/test_broken_functions.py index 1eed7ad1e..508122c92 100644 --- a/tests/unittests/test_broken_functions.py +++ b/tests/unittests/test_broken_functions.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + class TestMockHost(testutils.AsyncTestCase): broken_funcs_dir = testutils.UNIT_TESTS_FOLDER / 'broken_functions' diff --git a/tests/unittests/test_code_quality.py b/tests/unittests/test_code_quality.py index 40302ea3e..54d1cc725 100644 --- a/tests/unittests/test_code_quality.py +++ b/tests/unittests/test_code_quality.py @@ -5,7 +5,6 @@ import sys import unittest - ROOT_PATH = pathlib.Path(__file__).parent.parent.parent diff --git a/tests/unittests/test_datumref.py b/tests/unittests/test_datumref.py index 2d9ecb7f1..3db946467 100644 --- a/tests/unittests/test_datumref.py +++ b/tests/unittests/test_datumref.py @@ -7,12 +7,18 @@ from dateutil.parser import ParserError from azure_functions_worker import protos -from azure_functions_worker.bindings.datumdef import \ - parse_cookie_attr_expires, \ - parse_cookie_attr_same_site, parse_to_rpc_http_cookie_list, Datum -from azure_functions_worker.bindings.nullable_converters import \ - to_nullable_bool, to_nullable_string, to_nullable_double, \ - to_nullable_timestamp +from azure_functions_worker.bindings.datumdef import ( + Datum, + parse_cookie_attr_expires, + parse_cookie_attr_same_site, + parse_to_rpc_http_cookie_list, +) +from azure_functions_worker.bindings.nullable_converters import ( + to_nullable_bool, + to_nullable_double, + to_nullable_string, + to_nullable_timestamp, +) from azure_functions_worker.protos import RpcHttpCookie diff --git a/tests/unittests/test_dispatcher.py b/tests/unittests/test_dispatcher.py index 84d72e95b..5ee48f9eb 100644 --- a/tests/unittests/test_dispatcher.py +++ b/tests/unittests/test_dispatcher.py @@ -8,18 +8,21 @@ from typing import Optional, Tuple from unittest.mock import patch +from tests.utils import testutils +from tests.utils.testutils import UNIT_TESTS_ROOT + from azure_functions_worker import protos -from azure_functions_worker.constants import (PYTHON_THREADPOOL_THREAD_COUNT, - PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT, - PYTHON_THREADPOOL_THREAD_COUNT_MAX_37, - PYTHON_THREADPOOL_THREAD_COUNT_MIN, - PYTHON_ENABLE_INIT_INDEXING, - METADATA_PROPERTIES_WORKER_INDEXED, - PYTHON_ENABLE_DEBUG_LOGGING) +from azure_functions_worker.constants import ( + METADATA_PROPERTIES_WORKER_INDEXED, + PYTHON_ENABLE_DEBUG_LOGGING, + PYTHON_ENABLE_INIT_INDEXING, + PYTHON_THREADPOOL_THREAD_COUNT, + PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT, + PYTHON_THREADPOOL_THREAD_COUNT_MAX_37, + PYTHON_THREADPOOL_THREAD_COUNT_MIN, +) from azure_functions_worker.dispatcher import Dispatcher from azure_functions_worker.version import VERSION -from tests.utils import testutils -from tests.utils.testutils import UNIT_TESTS_ROOT SysVersionInfo = col.namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]) diff --git a/tests/unittests/test_enable_debug_logging_functions.py b/tests/unittests/test_enable_debug_logging_functions.py index 6f31c47ae..c39e7b60e 100644 --- a/tests/unittests/test_enable_debug_logging_functions.py +++ b/tests/unittests/test_enable_debug_logging_functions.py @@ -1,12 +1,13 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import typing import os +import typing from tests.utils import testutils -from azure_functions_worker.constants import PYTHON_ENABLE_DEBUG_LOGGING from tests.utils.testutils import TESTS_ROOT, remove_path +from azure_functions_worker.constants import PYTHON_ENABLE_DEBUG_LOGGING + HOST_JSON_TEMPLATE_WITH_LOGLEVEL_INFO = """\ { "version": "2.0", diff --git a/tests/unittests/test_extension.py b/tests/unittests/test_extension.py index c0b390f3f..62569fefd 100644 --- a/tests/unittests/test_extension.py +++ b/tests/unittests/test_extension.py @@ -8,15 +8,20 @@ import sys import unittest from importlib import import_module -from unittest.mock import patch, Mock, call +from unittest.mock import Mock, call, patch -from azure_functions_worker.constants import PYTHON_ENABLE_WORKER_EXTENSIONS, \ - CUSTOMER_PACKAGES_PATH +from azure_functions_worker.constants import ( + CUSTOMER_PACKAGES_PATH, + PYTHON_ENABLE_WORKER_EXTENSIONS, +) from azure_functions_worker.extension import ( + APP_EXT_POST_FUNCTION_LOAD, + APP_EXT_POST_INVOCATION, + APP_EXT_PRE_INVOCATION, + FUNC_EXT_POST_FUNCTION_LOAD, + FUNC_EXT_POST_INVOCATION, + FUNC_EXT_PRE_INVOCATION, ExtensionManager, - APP_EXT_POST_FUNCTION_LOAD, FUNC_EXT_POST_FUNCTION_LOAD, - APP_EXT_PRE_INVOCATION, FUNC_EXT_PRE_INVOCATION, - APP_EXT_POST_INVOCATION, FUNC_EXT_POST_INVOCATION ) from azure_functions_worker.utils.common import get_sdk_from_sys_path diff --git a/tests/unittests/test_file_accessor.py b/tests/unittests/test_file_accessor.py index 8c23b570d..97381229f 100644 --- a/tests/unittests/test_file_accessor.py +++ b/tests/unittests/test_file_accessor.py @@ -7,8 +7,10 @@ from unittest import skipIf from tests.utils import testutils -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryException + +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryException, +) @skipIf(sys.platform == 'darwin', 'MacOS M1 machines do not correctly test the' diff --git a/tests/unittests/test_file_accessor_factory.py b/tests/unittests/test_file_accessor_factory.py index 3c83f2310..143d09f71 100644 --- a/tests/unittests/test_file_accessor_factory.py +++ b/tests/unittests/test_file_accessor_factory.py @@ -6,12 +6,15 @@ import unittest from unittest.mock import patch -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import FileAccessorFactory -from azure_functions_worker.bindings.\ - shared_memory_data_transfer.file_accessor_unix import FileAccessorUnix -from azure_functions_worker.bindings.\ - shared_memory_data_transfer.file_accessor_windows import FileAccessorWindows +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + FileAccessorFactory, +) +from azure_functions_worker.bindings.shared_memory_data_transfer.file_accessor_unix import ( + FileAccessorUnix, +) +from azure_functions_worker.bindings.shared_memory_data_transfer.file_accessor_windows import ( + FileAccessorWindows, +) class TestFileAccessorFactory(unittest.TestCase): diff --git a/tests/unittests/test_functions_registry.py b/tests/unittests/test_functions_registry.py index e40e871df..4f28541d0 100644 --- a/tests/unittests/test_functions_registry.py +++ b/tests/unittests/test_functions_registry.py @@ -1,11 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from tests.utils import testutils - from azure.functions import Function from azure.functions.decorators.blob import BlobInput from azure.functions.decorators.http import HttpTrigger +from tests.utils import testutils from azure_functions_worker import functions from azure_functions_worker.functions import FunctionLoadError diff --git a/tests/unittests/test_http_functions_v2.py b/tests/unittests/test_http_functions_v2.py index f0849249e..17af822c1 100644 --- a/tests/unittests/test_http_functions_v2.py +++ b/tests/unittests/test_http_functions_v2.py @@ -10,9 +10,10 @@ from unittest import skipIf from unittest.mock import patch -from azure_functions_worker.constants import PYTHON_ENABLE_INIT_INDEXING from tests.utils import testutils +from azure_functions_worker.constants import PYTHON_ENABLE_INIT_INDEXING + @unittest.skipIf(sys.version_info.minor <= 7, "Skipping tests <= Python 3.7") class TestHttpFunctionsV2FastApi(testutils.WebHostTestCase): diff --git a/tests/unittests/test_http_v2.py b/tests/unittests/test_http_v2.py index 90d4d9b46..b2b1852fd 100644 --- a/tests/unittests/test_http_v2.py +++ b/tests/unittests/test_http_v2.py @@ -4,8 +4,12 @@ import unittest from unittest.mock import MagicMock, patch -from azure_functions_worker.http_v2 import http_coordinator, \ - AsyncContextReference, SingletonMeta, get_unused_tcp_port +from azure_functions_worker.http_v2 import ( + AsyncContextReference, + SingletonMeta, + get_unused_tcp_port, + http_coordinator, +) class MockHttpRequest: diff --git a/tests/unittests/test_invalid_stein.py b/tests/unittests/test_invalid_stein.py index e1e0e6417..1f65389d4 100644 --- a/tests/unittests/test_invalid_stein.py +++ b/tests/unittests/test_invalid_stein.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + STEIN_INVALID_APP_FUNCTIONS_DIR = testutils.UNIT_TESTS_FOLDER / \ 'broken_functions' / \ 'invalid_app_stein' diff --git a/tests/unittests/test_loader.py b/tests/unittests/test_loader.py index 6b48f6928..a6af8faa5 100644 --- a/tests/unittests/test_loader.py +++ b/tests/unittests/test_loader.py @@ -12,12 +12,14 @@ from azure.functions import Function from azure.functions.decorators.retry_policy import RetryPolicy from azure.functions.decorators.timer import TimerTrigger +from tests.utils import testutils from azure_functions_worker import functions -from azure_functions_worker.constants import PYTHON_SCRIPT_FILE_NAME, \ - PYTHON_SCRIPT_FILE_NAME_DEFAULT +from azure_functions_worker.constants import ( + PYTHON_SCRIPT_FILE_NAME, + PYTHON_SCRIPT_FILE_NAME_DEFAULT, +) from azure_functions_worker.loader import build_retry_protos -from tests.utils import testutils class TestLoader(testutils.WebHostTestCase): diff --git a/tests/unittests/test_main.py b/tests/unittests/test_main.py index 2fe29c8c1..688b4b0c1 100644 --- a/tests/unittests/test_main.py +++ b/tests/unittests/test_main.py @@ -1,6 +1,7 @@ -import unittest import sys +import unittest from unittest.mock import patch + from azure_functions_worker.main import parse_args diff --git a/tests/unittests/test_mock_blob_shared_memory_functions.py b/tests/unittests/test_mock_blob_shared_memory_functions.py index f3cee34ac..cdbbfc920 100644 --- a/tests/unittests/test_mock_blob_shared_memory_functions.py +++ b/tests/unittests/test_mock_blob_shared_memory_functions.py @@ -1,19 +1,20 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import json import hashlib +import json +import sys import time from unittest import skipIf -import sys -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryMap -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryConstants as consts -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryConstants as consts, +) +from azure_functions_worker.bindings.shared_memory_data_transfer import SharedMemoryMap + @skipIf(sys.platform == 'darwin', 'MacOS M1 machines do not correctly test the' 'shared memory filesystems and thus skipping' diff --git a/tests/unittests/test_mock_durable_functions.py b/tests/unittests/test_mock_durable_functions.py index daeef65a0..ce19c613f 100644 --- a/tests/unittests/test_mock_durable_functions.py +++ b/tests/unittests/test_mock_durable_functions.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + class TestDurableFunctions(testutils.AsyncTestCase): durable_functions_dir = testutils.UNIT_TESTS_FOLDER / 'durable_functions' diff --git a/tests/unittests/test_mock_eventhub_functions.py b/tests/unittests/test_mock_eventhub_functions.py index 8fa544e84..f93dfa994 100644 --- a/tests/unittests/test_mock_eventhub_functions.py +++ b/tests/unittests/test_mock_eventhub_functions.py @@ -2,9 +2,10 @@ # Licensed under the MIT License. import json -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + class TestEventHubMockFunctions(testutils.AsyncTestCase): mock_funcs_dir = testutils.UNIT_TESTS_FOLDER / 'eventhub_mock_functions' diff --git a/tests/unittests/test_mock_generic_functions.py b/tests/unittests/test_mock_generic_functions.py index 159ec681e..5ae199bbf 100644 --- a/tests/unittests/test_mock_generic_functions.py +++ b/tests/unittests/test_mock_generic_functions.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + class TestGenericFunctions(testutils.AsyncTestCase): generic_funcs_dir = testutils.UNIT_TESTS_FOLDER / 'generic_functions' diff --git a/tests/unittests/test_mock_http_functions.py b/tests/unittests/test_mock_http_functions.py index f7538065d..849134038 100644 --- a/tests/unittests/test_mock_http_functions.py +++ b/tests/unittests/test_mock_http_functions.py @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + class TestMockHost(testutils.AsyncTestCase): diff --git a/tests/unittests/test_mock_log_filtering_functions.py b/tests/unittests/test_mock_log_filtering_functions.py index 81e676c22..022499502 100644 --- a/tests/unittests/test_mock_log_filtering_functions.py +++ b/tests/unittests/test_mock_log_filtering_functions.py @@ -1,9 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from unittest.mock import patch, call +from unittest.mock import call, patch -from azure_functions_worker import protos from tests.utils import testutils + +from azure_functions_worker import protos from azure_functions_worker.logging import is_system_log_category diff --git a/tests/unittests/test_mock_timer_functions.py b/tests/unittests/test_mock_timer_functions.py index 7bdda8ee1..d4f11e644 100644 --- a/tests/unittests/test_mock_timer_functions.py +++ b/tests/unittests/test_mock_timer_functions.py @@ -2,9 +2,10 @@ # Licensed under the MIT License. import json -from azure_functions_worker import protos from tests.utils import testutils +from azure_functions_worker import protos + class TestTimerFunctions(testutils.AsyncTestCase): timer_funcs_dir = testutils.UNIT_TESTS_FOLDER / 'timer_functions' diff --git a/tests/unittests/test_nullable_converters.py b/tests/unittests/test_nullable_converters.py index 6ac617459..913c80fb7 100644 --- a/tests/unittests/test_nullable_converters.py +++ b/tests/unittests/test_nullable_converters.py @@ -5,9 +5,12 @@ from google.protobuf.timestamp_pb2 import Timestamp from azure_functions_worker import protos -from azure_functions_worker.bindings.nullable_converters import \ - to_nullable_string, to_nullable_bool, to_nullable_double, \ - to_nullable_timestamp +from azure_functions_worker.bindings.nullable_converters import ( + to_nullable_bool, + to_nullable_double, + to_nullable_string, + to_nullable_timestamp, +) try: from http.cookies import SimpleCookie diff --git a/tests/unittests/test_opentelemetry.py b/tests/unittests/test_opentelemetry.py index bf785b7a6..cee4d82f8 100644 --- a/tests/unittests/test_opentelemetry.py +++ b/tests/unittests/test_opentelemetry.py @@ -1,11 +1,12 @@ import asyncio import unittest -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch -from azure_functions_worker import protos from tests.unittests.test_dispatcher import FUNCTION_APP_DIRECTORY from tests.utils import testutils +from azure_functions_worker import protos + class TestOpenTelemetry(unittest.TestCase): diff --git a/tests/unittests/test_rpc_messages.py b/tests/unittests/test_rpc_messages.py index a1129a318..4e3a6c23d 100644 --- a/tests/unittests/test_rpc_messages.py +++ b/tests/unittests/test_rpc_messages.py @@ -7,9 +7,10 @@ import typing import unittest +from tests.utils import testutils + from azure_functions_worker import protos from azure_functions_worker.utils.common import is_python_version -from tests.utils import testutils class TestGRPC(testutils.AsyncTestCase): diff --git a/tests/unittests/test_script_file_name.py b/tests/unittests/test_script_file_name.py index 43da69f87..24327249a 100644 --- a/tests/unittests/test_script_file_name.py +++ b/tests/unittests/test_script_file_name.py @@ -3,8 +3,11 @@ import os from tests.utils import testutils -from azure_functions_worker.constants import \ - PYTHON_SCRIPT_FILE_NAME, PYTHON_SCRIPT_FILE_NAME_DEFAULT + +from azure_functions_worker.constants import ( + PYTHON_SCRIPT_FILE_NAME, + PYTHON_SCRIPT_FILE_NAME_DEFAULT, +) DEFAULT_SCRIPT_FILE_NAME_DIR = testutils.UNIT_TESTS_FOLDER / \ 'file_name_functions' / \ diff --git a/tests/unittests/test_shared_memory_manager.py b/tests/unittests/test_shared_memory_manager.py index 60a89e3ea..ca3cb6088 100644 --- a/tests/unittests/test_shared_memory_manager.py +++ b/tests/unittests/test_shared_memory_manager.py @@ -1,21 +1,26 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +import json import math import os -import json import sys from unittest import skipIf from unittest.mock import patch -from azure_functions_worker.utils.common import is_envvar_true + from azure.functions import meta as bind_meta from tests.utils import testutils -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryManager -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryConstants as consts -from azure_functions_worker.constants \ - import FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED + +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryConstants as consts, +) +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryManager, +) +from azure_functions_worker.constants import ( + FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED, +) +from azure_functions_worker.utils.common import is_envvar_true @skipIf(sys.platform == 'darwin', 'MacOS M1 machines do not correctly test the' diff --git a/tests/unittests/test_shared_memory_map.py b/tests/unittests/test_shared_memory_map.py index 7fdd53f73..ecaeaacc0 100644 --- a/tests/unittests/test_shared_memory_map.py +++ b/tests/unittests/test_shared_memory_map.py @@ -7,12 +7,14 @@ from unittest import skipIf from tests.utils import testutils -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryMap -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryConstants as consts -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryException + +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryConstants as consts, +) +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryException, + SharedMemoryMap, +) @skipIf(sys.platform == 'darwin', 'MacOS M1 machines do not correctly test the' diff --git a/tests/unittests/test_types.py b/tests/unittests/test_types.py index e083c503f..963f26914 100644 --- a/tests/unittests/test_types.py +++ b/tests/unittests/test_types.py @@ -5,6 +5,7 @@ from azure import functions as azf from azure.functions import http as bind_http from azure.functions import meta as bind_meta + from azure_functions_worker import protos from azure_functions_worker.bindings import datumdef diff --git a/tests/unittests/test_typing_inspect.py b/tests/unittests/test_typing_inspect.py index 74004b849..4f01e4c73 100644 --- a/tests/unittests/test_typing_inspect.py +++ b/tests/unittests/test_typing_inspect.py @@ -4,14 +4,39 @@ # Author: Ivan Levkivskyi # License: MIT -from azure_functions_worker._thirdparty.typing_inspect import ( - is_generic_type, is_callable_type, is_tuple_type, is_union_type, - is_typevar, is_classvar, get_origin, get_parameters, get_last_args, get_args, - get_generic_type, get_generic_bases, get_last_origin, ) -from unittest import TestCase, main, skipIf from typing import ( - Union, ClassVar, Callable, Optional, TypeVar, Sequence, Mapping, - MutableMapping, Iterable, Generic, List, Any, Dict, Tuple, NamedTuple, + Any, + Callable, + ClassVar, + Dict, + Generic, + Iterable, + List, + Mapping, + MutableMapping, + NamedTuple, + Optional, + Sequence, + Tuple, + TypeVar, + Union, +) +from unittest import TestCase, main, skipIf + +from azure_functions_worker._thirdparty.typing_inspect import ( + get_args, + get_generic_bases, + get_generic_type, + get_last_args, + get_last_origin, + get_origin, + get_parameters, + is_callable_type, + is_classvar, + is_generic_type, + is_tuple_type, + is_typevar, + is_union_type, ) diff --git a/tests/unittests/test_utilities_dependency.py b/tests/unittests/test_utilities_dependency.py index fd4a31a85..432aee750 100644 --- a/tests/unittests/test_utilities_dependency.py +++ b/tests/unittests/test_utilities_dependency.py @@ -6,9 +6,10 @@ import unittest from unittest.mock import patch -from azure_functions_worker.utils.dependency import DependencyManager from tests.utils import testutils +from azure_functions_worker.utils.dependency import DependencyManager + class TestDependencyManager(unittest.TestCase): @@ -219,7 +220,7 @@ def test_add_to_sys_path_no_duplication(self): def test_add_to_sys_path_import_module(self): DependencyManager._add_to_sys_path(self._customer_deps_path, True) - import common_module # NoQA + import common_module # NoQA self.assertEqual( common_module.package_location, os.path.join(self._customer_deps_path, 'common_module') @@ -230,7 +231,7 @@ def test_add_to_sys_path_import_namespace_path(self): into sys.path """ DependencyManager._add_to_sys_path(self._customer_deps_path, True) - import common_namespace # NoQA + import common_namespace # NoQA self.assertEqual(len(common_namespace.__path__), 1) self.assertEqual( common_namespace.__path__[0], @@ -507,7 +508,7 @@ def test_clear_path_importer_cache_and_modules_retain_namespace(self): sys.path.insert(0, self._worker_deps_path) # Ensure new import is from _worker_deps_path - import common_module as worker_mod # NoQA + import common_module as worker_mod # NoQA self.assertIn('common_module', sys.modules) self.assertEqual( worker_mod.package_location, diff --git a/tests/unittests/third_party_http_functions/stein/wsgi_function/function_app.py b/tests/unittests/third_party_http_functions/stein/wsgi_function/function_app.py index d08b3dc61..7605b4b19 100644 --- a/tests/unittests/third_party_http_functions/stein/wsgi_function/function_app.py +++ b/tests/unittests/third_party_http_functions/stein/wsgi_function/function_app.py @@ -3,7 +3,7 @@ from urllib.request import urlopen import azure.functions as func -from flask import Flask, request, Response, redirect, url_for +from flask import Flask, Response, redirect, request, url_for flask_app = Flask(__name__) logger = logging.getLogger("my-function") diff --git a/tests/unittests/timer_functions/user_event_loop_timer/main.py b/tests/unittests/timer_functions/user_event_loop_timer/main.py index 0e3decdbd..0bb039078 100644 --- a/tests/unittests/timer_functions/user_event_loop_timer/main.py +++ b/tests/unittests/timer_functions/user_event_loop_timer/main.py @@ -1,11 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import logging import asyncio +import logging import azure.functions as func - logger = logging.getLogger('my function') diff --git a/tests/utils/testutils.py b/tests/utils/testutils.py index 61dbf6dc8..85beacd40 100644 --- a/tests/utils/testutils.py +++ b/tests/utils/testutils.py @@ -33,24 +33,35 @@ import grpc import requests +from tests.utils.constants import ( + ARCHIVE_WEBHOST_LOGS, + CONSUMPTION_DOCKER_TEST, + DEDICATED_DOCKER_TEST, + EXTENSIONS_CSPROJ_TEMPLATE, + PROJECT_ROOT, + PYAZURE_INTEGRATION_TEST, + PYAZURE_WEBHOST_DEBUG, + PYAZURE_WORKER_DIR, + WORKER_CONFIG, +) +from tests.utils.testutils_docker import ( + DockerConfigs, + WebHostConsumption, + WebHostDedicated, +) -from azure_functions_worker import dispatcher -from azure_functions_worker import protos -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import FileAccessorFactory -from azure_functions_worker.bindings.shared_memory_data_transfer \ - import SharedMemoryConstants as consts +from azure_functions_worker import dispatcher, protos +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + FileAccessorFactory, +) +from azure_functions_worker.bindings.shared_memory_data_transfer import ( + SharedMemoryConstants as consts, +) from azure_functions_worker.constants import ( FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED, - UNIX_SHARED_MEMORY_DIRECTORIES + UNIX_SHARED_MEMORY_DIRECTORIES, ) -from azure_functions_worker.utils.common import is_envvar_true, get_app_setting -from tests.utils.constants import PYAZURE_WORKER_DIR, \ - PYAZURE_INTEGRATION_TEST, PROJECT_ROOT, WORKER_CONFIG, \ - CONSUMPTION_DOCKER_TEST, DEDICATED_DOCKER_TEST, PYAZURE_WEBHOST_DEBUG, \ - ARCHIVE_WEBHOST_LOGS, EXTENSIONS_CSPROJ_TEMPLATE -from tests.utils.testutils_docker import WebHostConsumption, WebHostDedicated, \ - DockerConfigs +from azure_functions_worker.utils.common import get_app_setting, is_envvar_true TESTS_ROOT = PROJECT_ROOT / 'tests' E2E_TESTS_FOLDER = pathlib.Path('endtoend') diff --git a/tests/utils/testutils_docker.py b/tests/utils/testutils_docker.py index 484cfd242..964d8a83e 100644 --- a/tests/utils/testutils_docker.py +++ b/tests/utils/testutils_docker.py @@ -10,7 +10,6 @@ from time import sleep import requests - from tests.utils.constants import PROJECT_ROOT, TESTS_ROOT _DOCKER_PATH = "DOCKER_PATH" diff --git a/tests/utils/testutils_lc.py b/tests/utils/testutils_lc.py index 0f6638195..d0065d97f 100644 --- a/tests/utils/testutils_lc.py +++ b/tests/utils/testutils_lc.py @@ -19,7 +19,6 @@ from Crypto.Cipher import AES from Crypto.Hash.SHA256 import SHA256Hash from Crypto.Util.Padding import pad - from tests.utils.constants import PROJECT_ROOT # Linux Consumption Testing Constants