From 6c22ba2b8424374b4ff01aeba6a516dfdf180dde Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Thu, 29 Mar 2018 11:04:00 +0200 Subject: [PATCH 01/12] Run tests on Python 3.7 development branch --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 742100ac9..d90eeb125 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ python: - 3.6.3 - 3.6 - 3.6-dev # 3.6 development branch + - 3.7-dev # 3.7 development branch services: - rabbitmq install: From 064d40f94cabe8ed582c9736fb4902874eeb18af Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Wed, 30 May 2018 23:46:31 +0200 Subject: [PATCH 02/12] Install pycparser first --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5815399a9..3abae3075 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ python: services: - rabbitmq install: + - travis_retry pip install pycparser==2.18 - travis_retry pip install -e . - travis_retry pip install -Ur requirements.txt - pip freeze From 35961eeaeef007e150159c22f7e5030bcf7e4323 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Thu, 31 May 2018 00:01:17 +0200 Subject: [PATCH 03/12] Added pycparser to requirements --- .travis.yml | 1 - requirements.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3abae3075..5815399a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ python: services: - rabbitmq install: - - travis_retry pip install pycparser==2.18 - travis_retry pip install -e . - travis_retry pip install -Ur requirements.txt - pip freeze diff --git a/requirements.txt b/requirements.txt index c4d104ed7..b095ab738 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +pycparser==2.18 aioamqp==0.10.0 aiobotocore==0.8.0 aiodns==1.1.1 From b0c75223579c768927f33f2b89d2aca11d750388 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Tue, 5 Jun 2018 17:48:30 +0200 Subject: [PATCH 04/12] Added pycparser to setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 2642e12f3..65261337a 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ import tomodachi.__version__ install_requires = [ + 'pycparser=>2.18', 'aioamqp>=0.10.0, <0.11.0', 'ujson>=1.35', 'uvloop>=0.8.1', From 42d1d3a54fd4ca48c84e77f9de4e9664bbb41636 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Tue, 5 Jun 2018 17:48:55 +0200 Subject: [PATCH 05/12] Added pycparser to setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 65261337a..72b5e394d 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import tomodachi.__version__ install_requires = [ - 'pycparser=>2.18', + 'pycparser>=2.18', 'aioamqp>=0.10.0, <0.11.0', 'ujson>=1.35', 'uvloop>=0.8.1', From a4fecfec5c479ae2a486097ecb0bf38a30fbda84 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Fri, 29 Jun 2018 10:16:22 +0200 Subject: [PATCH 06/12] Added classifiers for Python 3.7 --- README.rst | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a04a95d63..22426b750 100644 --- a/README.rst +++ b/README.rst @@ -247,7 +247,7 @@ Nothing more nothing less. It's actually as easy as that. Requirements 👍 --------------- -* Python_ 3.5.3+, 3.6+ +* Python_ 3.5.3+, 3.6+, 3.7+ * aiohttp_ * aiobotocore_ * aioamqp_ diff --git a/setup.py b/setup.py index 0c79b4822..cdef33253 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ def read(f: str) -> str: 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'License :: OSI Approved :: MIT License', 'Development Status :: 2 - Pre-Alpha', 'Topic :: Software Development :: Libraries :: Application Frameworks', From 579d32406aa4175c2f85a94d6ec740c1b0b32f0c Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 2 Jul 2018 22:20:10 +0200 Subject: [PATCH 07/12] Updated travis config --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5815399a9..8ac4bf6c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: python -sudo: required +sudo: true +dist: xenial python: - 3.5.3 - 3.5.4 @@ -10,6 +11,8 @@ python: - 3.6.3 - 3.6.4 - 3.6.5 + - 3.6.6 + - 3.7.0 - 3.6-dev # 3.6 development branch - 3.7-dev # 3.7 development branch services: From 66fb0463613138127472f1330f413f265765355c Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 2 Jul 2018 22:34:01 +0200 Subject: [PATCH 08/12] Removed inconclusive Python 3.7 tests --- tests/test_non_packaged_imported_service.py | 32 --------------------- 1 file changed, 32 deletions(-) diff --git a/tests/test_non_packaged_imported_service.py b/tests/test_non_packaged_imported_service.py index 89efb9593..fb8e92247 100644 --- a/tests/test_non_packaged_imported_service.py +++ b/tests/test_non_packaged_imported_service.py @@ -67,56 +67,24 @@ def test_sub_service(monkeypatch: Any, capsys: Any, loop: Any) -> None: services, future = start_service('tests/services/test/service.py', monkeypatch) -@pytest.mark.skipif(sys.version_info < (3, 7, 0), reason="Test executes only on Python 3.7") -def test_sub_service_py37(monkeypatch: Any, capsys: Any, loop: Any) -> None: - services, future = start_service('tests/services/test/service.py', monkeypatch) - - os.kill(os.getpid(), signal.SIGINT) - loop.run_until_complete(future) - - @pytest.mark.skipif(sys.version_info >= (3, 7, 0), reason="Test skipped on Python 3.7") def test_sub_service_without_py_ending(monkeypatch: Any, capsys: Any, loop: Any) -> None: with pytest.raises(tomodachi.importer.ServicePackageError): services, future = start_service('tests/services/test/service', monkeypatch) -@pytest.mark.skipif(sys.version_info < (3, 7, 0), reason="Test executes only on Python 3.7") -def test_sub_service_without_py_ending_py37(monkeypatch: Any, capsys: Any, loop: Any) -> None: - services, future = start_service('tests/services/test/service', monkeypatch) - - os.kill(os.getpid(), signal.SIGINT) - loop.run_until_complete(future) - - @pytest.mark.skipif(sys.version_info >= (3, 7, 0), reason="Test skipped on Python 3.7") def test_same_named_sub_service(monkeypatch: Any, capsys: Any, loop: Any) -> None: with pytest.raises(tomodachi.importer.ServicePackageError): services, future = start_service('tests/services/test/test.py', monkeypatch) -@pytest.mark.skipif(sys.version_info < (3, 7, 0), reason="Test executes only on Python 3.7") -def test_same_named_sub_service_py37(monkeypatch: Any, capsys: Any, loop: Any) -> None: - services, future = start_service('tests/services/test/test.py', monkeypatch) - - os.kill(os.getpid(), signal.SIGINT) - loop.run_until_complete(future) - - @pytest.mark.skipif(sys.version_info >= (3, 7, 0), reason="Test skipped on Python 3.7") def test_same_named_sub_service_without_py_ending(monkeypatch: Any, capsys: Any, loop: Any) -> None: with pytest.raises(tomodachi.importer.ServicePackageError): services, future = start_service('tests/services/test/test', monkeypatch) -@pytest.mark.skipif(sys.version_info < (3, 7, 0), reason="Test executes only on Python 3.7") -def test_same_named_sub_service_without_py_ending_py37(monkeypatch: Any, capsys: Any, loop: Any) -> None: - services, future = start_service('tests/services/test/test', monkeypatch) - - os.kill(os.getpid(), signal.SIGINT) - loop.run_until_complete(future) - - def test_sub_service_with_reserved_name(monkeypatch: Any, capsys: Any, loop: Any) -> None: with pytest.raises(tomodachi.importer.ServicePackageError): services, future = start_service('tests/services/os/os.py', monkeypatch) From 8d242f120dd7a4d814a67f8b5ffe35c7d4fa455f Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 2 Jul 2018 22:35:04 +0200 Subject: [PATCH 09/12] Reverted travis file back to using Trusty --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ac4bf6c1..172e02315 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python -sudo: true -dist: xenial +sudo: required python: - 3.5.3 - 3.5.4 From 7c450823b2fa56818c8ddb9ff15e35914cc5a914 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 2 Jul 2018 22:51:10 +0200 Subject: [PATCH 10/12] Handle import error --- .travis.yml | 1 - tomodachi/importer.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 172e02315..5d6c5822a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ python: - 3.6.4 - 3.6.5 - 3.6.6 - - 3.7.0 - 3.6-dev # 3.6 development branch - 3.7-dev # 3.7 development branch services: diff --git a/tomodachi/importer.py b/tomodachi/importer.py index d5662e631..26c91d68b 100644 --- a/tomodachi/importer.py +++ b/tomodachi/importer.py @@ -48,7 +48,9 @@ def import_service_file(cls, file_name: str) -> ModuleType: except ModuleNotFoundError as e: # noqa file_path_package_name = file_path[:-3] if file_path.endswith('.py') else file_path if str(e) == "__path__ attribute not found on '{}' while trying to find '{}'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])): - # ModuleNotFoundError: __path__ attribute not found on 'os' while trying to find 'os.code' + logging.getLogger('import').warning('Invalid service package/parent name, may conflict with Python internals: "{}" - change parent folder name'.format(file_path.rsplit('/', 2)[1])) + raise ServicePackageError from e + if str(e) == "module '{}' has no attribute '__path__'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])): logging.getLogger('import').warning('Invalid service package/parent name, may conflict with Python internals: "{}" - change parent folder name'.format(file_path.rsplit('/', 2)[1])) raise ServicePackageError from e raise e From 2b71322d7f428b4122c54dd09c2f34bf172ac3dc Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 2 Jul 2018 23:04:17 +0200 Subject: [PATCH 11/12] Fix for malformed error message in Python 3.7 --- tomodachi/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tomodachi/importer.py b/tomodachi/importer.py index 26c91d68b..ce50a6c2a 100644 --- a/tomodachi/importer.py +++ b/tomodachi/importer.py @@ -50,7 +50,7 @@ def import_service_file(cls, file_name: str) -> ModuleType: if str(e) == "__path__ attribute not found on '{}' while trying to find '{}'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])): logging.getLogger('import').warning('Invalid service package/parent name, may conflict with Python internals: "{}" - change parent folder name'.format(file_path.rsplit('/', 2)[1])) raise ServicePackageError from e - if str(e) == "module '{}' has no attribute '__path__'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])): + if str(e) == "__path__ attribute not found on '{}'while trying to find '{}'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])): logging.getLogger('import').warning('Invalid service package/parent name, may conflict with Python internals: "{}" - change parent folder name'.format(file_path.rsplit('/', 2)[1])) raise ServicePackageError from e raise e From baadca7f4a2040a77d3c1cf920d95c7b6f8bdfa8 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 2 Jul 2018 23:24:44 +0200 Subject: [PATCH 12/12] Linting fixes --- Makefile | 3 +-- requirements.txt | 2 +- tests/run_test_service_helper.py | 6 +++--- .../amqp_service_with_credentials_without_protocol.py | 2 +- ...ns_sqs_service_with_credentials_without_protocol.py | 2 +- tests/services/mock_decorator_service.py | 2 +- tomodachi/cli/__init__.py | 2 +- tomodachi/container.py | 2 +- tomodachi/helpers/logging.py | 2 +- tomodachi/invoker/decorator.py | 2 +- tomodachi/launcher.py | 2 +- tomodachi/transport/amqp.py | 10 +++++----- tomodachi/transport/aws_sns_sqs.py | 10 +++++----- tomodachi/transport/http.py | 10 +++++----- tomodachi/transport/schedule.py | 8 ++++---- tomodachi/validation/validation.py | 2 +- tomodachi/watcher.py | 6 +++--- 17 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index d655eb537..bf128e104 100644 --- a/Makefile +++ b/Makefile @@ -26,14 +26,13 @@ install: pip install -U . development: - pip install -r requirements-dev.txt pip install -r requirements.txt uninstall: pip uninstall -y tomodachi lint: - pycodestyle --ignore E501 --exclude proto_build . + pycodestyle --ignore E501 --exclude proto_build,build . mypy ./ @echo "ok" diff --git a/requirements.txt b/requirements.txt index d5fde2a7c..bda2f2dc6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ mypy==0.610 packaging==17.1 protobuf==3.6.0 pycares==2.3.0 -pycodestyle==2.3.1 +pycodestyle==2.4.0 py==1.5.4 pyparsing==2.2.0 pytest==3.6.2 diff --git a/tests/run_test_service_helper.py b/tests/run_test_service_helper.py index 7ea53b0b8..9d1f14624 100644 --- a/tests/run_test_service_helper.py +++ b/tests/run_test_service_helper.py @@ -7,19 +7,19 @@ from tomodachi.importer import ServiceImporter -def start_service(filename: str, monkeypatch: Any=None) -> Tuple: +def start_service(filename: str, monkeypatch: Any = None) -> Tuple: if monkeypatch: monkeypatch.setattr(logging.root, 'handlers', []) loop = asyncio.get_event_loop() # type: Any service = None # type: Any - def stop_services(loop: Any=None) -> None: + def stop_services(loop: Any = None) -> None: if not loop: loop = asyncio.get_event_loop() asyncio.ensure_future(_stop_services()) - def force_stop_services(loop: Any=None) -> None: + def force_stop_services(loop: Any = None) -> None: if not loop: loop = asyncio.get_event_loop() asyncio.ensure_future(_force_stop_services()) diff --git a/tests/services/amqp_service_with_credentials_without_protocol.py b/tests/services/amqp_service_with_credentials_without_protocol.py index 500092abe..6993ff269 100644 --- a/tests/services/amqp_service_with_credentials_without_protocol.py +++ b/tests/services/amqp_service_with_credentials_without_protocol.py @@ -30,7 +30,7 @@ def check_closer(self): self.closer.set_result(None) @amqp('test.raw.topic') - async def test(self, value: Any, default_value: bool=True) -> None: + async def test(self, value: Any, default_value: bool = True) -> None: if value == self.data_uuid: self.test_topic_data_received = default_value self.test_topic_data = value diff --git a/tests/services/aws_sns_sqs_service_with_credentials_without_protocol.py b/tests/services/aws_sns_sqs_service_with_credentials_without_protocol.py index b69b56be6..f6c61d4f7 100644 --- a/tests/services/aws_sns_sqs_service_with_credentials_without_protocol.py +++ b/tests/services/aws_sns_sqs_service_with_credentials_without_protocol.py @@ -36,7 +36,7 @@ def check_closer(self): self.closer.set_result(None) @aws_sns_sqs('test-raw-topic') - async def test(self, value: Any, default_value: bool=True) -> None: + async def test(self, value: Any, default_value: bool = True) -> None: if value == self.data_uuid: self.test_topic_data_received = default_value self.test_topic_data = value diff --git a/tests/services/mock_decorator_service.py b/tests/services/mock_decorator_service.py index 906f62c0a..4477e8d15 100644 --- a/tests/services/mock_decorator_service.py +++ b/tests/services/mock_decorator_service.py @@ -9,5 +9,5 @@ class MockDecoratorService(tomodachi.Service): function_tested = False @aws_sns_sqs('test-topic') - async def test(self, default_value: bool=True) -> None: + async def test(self, default_value: bool = True) -> None: self.function_tested = default_value diff --git a/tomodachi/cli/__init__.py b/tomodachi/cli/__init__.py index 842a8bb2c..9cc15f433 100644 --- a/tomodachi/cli/__init__.py +++ b/tomodachi/cli/__init__.py @@ -130,7 +130,7 @@ def main(self, argv: List[str]) -> None: self.help_command() -def cli_entrypoint(argv: Optional[List[str]]=None) -> None: +def cli_entrypoint(argv: Optional[List[str]] = None) -> None: if argv is None: argv = sys.argv CLI().main(argv[1:]) diff --git a/tomodachi/container.py b/tomodachi/container.py index 734407e31..dc975c560 100644 --- a/tomodachi/container.py +++ b/tomodachi/container.py @@ -13,7 +13,7 @@ class ServiceContainer(object): - def __init__(self, module_import: ModuleType, configuration: Optional[Dict]=None) -> None: + def __init__(self, module_import: ModuleType, configuration: Optional[Dict] = None) -> None: self.module_import = module_import self.file_path = module_import.__file__ diff --git a/tomodachi/helpers/logging.py b/tomodachi/helpers/logging.py index 4117c292f..819e9ce72 100644 --- a/tomodachi/helpers/logging.py +++ b/tomodachi/helpers/logging.py @@ -3,7 +3,7 @@ from typing import Optional, Union, Any -def log_setup(service: Any, name: Optional[str]=None, level: Optional[Union[str, int]]=None, formatter: Optional[Union[logging.Formatter, str, bool]]=True, filename: Optional[str]=None) -> logging.Logger: +def log_setup(service: Any, name: Optional[str] = None, level: Optional[Union[str, int]] = None, formatter: Optional[Union[logging.Formatter, str, bool]] = True, filename: Optional[str] = None) -> logging.Logger: if not name: name = 'log.{}'.format(service.name) if not filename: diff --git a/tomodachi/invoker/decorator.py b/tomodachi/invoker/decorator.py index 2b39676ae..88053f291 100644 --- a/tomodachi/invoker/decorator.py +++ b/tomodachi/invoker/decorator.py @@ -43,7 +43,7 @@ def __repr__(self) -> str: return ''.format(self.__qualname__, hex(id(self))) -def decorator(include_function: Any=False) -> Callable: +def decorator(include_function: Any = False) -> Callable: fn = None if include_function and callable(include_function): fn = include_function diff --git a/tomodachi/launcher.py b/tomodachi/launcher.py index dfd243eee..6399dea56 100644 --- a/tomodachi/launcher.py +++ b/tomodachi/launcher.py @@ -25,7 +25,7 @@ class ServiceLauncher(object): services = set() # type: set @classmethod - def run_until_complete(cls, service_files: Union[List, set], configuration: Optional[Dict]=None, watcher: Optional[tomodachi.watcher.Watcher]=None) -> None: + def run_until_complete(cls, service_files: Union[List, set], configuration: Optional[Dict] = None, watcher: Optional[tomodachi.watcher.Watcher] = None) -> None: def stop_services() -> None: asyncio.ensure_future(_stop_services()) diff --git a/tomodachi/transport/amqp.py b/tomodachi/transport/amqp.py index e65fa1a2d..5f385dd63 100644 --- a/tomodachi/transport/amqp.py +++ b/tomodachi/transport/amqp.py @@ -49,7 +49,7 @@ class AmqpTransport(Invoker): transport = None # type: Any @classmethod - async def publish(cls, service: Any, data: Any, routing_key: str='', exchange_name: str='', wait: bool=True) -> None: + async def publish(cls, service: Any, data: Any, routing_key: str = '', exchange_name: str = '', wait: bool = True) -> None: if not cls.channel: await cls.connect(cls, service, service.context) exchange_name = exchange_name or cls.exchange_name or 'amq.topic' @@ -114,7 +114,7 @@ def prefix_queue_name(cls, queue_name: str, context: Dict) -> str: return '{}{}'.format(context.get('options', {}).get('amqp', {}).get('queue_name_prefix'), queue_name) return queue_name - async def subscribe_handler(cls: Any, obj: Any, context: Dict, func: Any, routing_key: str, callback_kwargs: Optional[Union[list, set, tuple]]=None, exchange_name: str='', competing: Optional[bool]=None, queue_name: Optional[str]=None) -> Any: + async def subscribe_handler(cls: Any, obj: Any, context: Dict, func: Any, routing_key: str, callback_kwargs: Optional[Union[list, set, tuple]] = None, exchange_name: str = '', competing: Optional[bool] = None, queue_name: Optional[str] = None) -> Any: async def handler(payload: Any, delivery_tag: Any) -> Any: _callback_kwargs = callback_kwargs # type: Any values = inspect.getfullargspec(func) @@ -264,9 +264,9 @@ async def subscribe(cls: Any, obj: Any, context: Dict) -> Optional[Callable]: channel = await cls.connect(cls, obj, context) async def _subscribe() -> None: - async def declare_queue(routing_key: str, func: Callable, exchange_name: str='', exchange_type: str='topic', queue_name: Optional[str]=None, - passive: bool=False, durable: bool=True, exclusive: bool=False, auto_delete: bool=False, - competing_consumer: Optional[bool]=None) -> Optional[str]: + async def declare_queue(routing_key: str, func: Callable, exchange_name: str = '', exchange_type: str = 'topic', queue_name: Optional[str] = None, + passive: bool = False, durable: bool = True, exclusive: bool = False, auto_delete: bool = False, + competing_consumer: Optional[bool] = None) -> Optional[str]: try: if exchange_name and exchange_name != 'amq.topic': await channel.exchange_declare(exchange_name=exchange_name, type_name=exchange_type, passive=False, durable=True, auto_delete=False) diff --git a/tomodachi/transport/aws_sns_sqs.py b/tomodachi/transport/aws_sns_sqs.py index 99b1f3836..527b5e46e 100644 --- a/tomodachi/transport/aws_sns_sqs.py +++ b/tomodachi/transport/aws_sns_sqs.py @@ -44,7 +44,7 @@ class AWSSNSSQSTransport(Invoker): close_waiter = None @classmethod - async def publish(cls, service: Any, data: Any, topic: str, wait: bool=True) -> None: + async def publish(cls, service: Any, data: Any, topic: str, wait: bool = True) -> None: message_protocol = getattr(service, 'message_protocol', None) payload = data @@ -101,7 +101,7 @@ def prefix_queue_name(cls, queue_name: str, context: Dict) -> str: return '{}{}'.format(context.get('options', {}).get('aws_sns_sqs', {}).get('queue_name_prefix'), queue_name) return queue_name - async def subscribe_handler(cls: Any, obj: Any, context: Dict, func: Any, topic: str, callback_kwargs: Optional[Union[list, set, tuple]]=None, competing: Optional[bool]=None, queue_name: Optional[str]=None, **kwargs: Any) -> Any: + async def subscribe_handler(cls: Any, obj: Any, context: Dict, func: Any, topic: str, callback_kwargs: Optional[Union[list, set, tuple]] = None, competing: Optional[bool] = None, queue_name: Optional[str] = None, **kwargs: Any) -> Any: parser_kwargs = kwargs message_protocol = context.get('message_protocol') # Validate the parser kwargs if there is a validation function in the @@ -111,7 +111,7 @@ async def subscribe_handler(cls: Any, obj: Any, context: Dict, func: Any, topic: if protocol_kwargs_validation_func: protocol_kwargs_validation_func(**parser_kwargs) - async def handler(payload: Optional[str], receipt_handle: Optional[str]=None, queue_url: Optional[str]=None) -> Any: + async def handler(payload: Optional[str], receipt_handle: Optional[str] = None, queue_url: Optional[str] = None) -> Any: if not payload or payload == DRAIN_MESSAGE_PAYLOAD: await cls.delete_message(cls, receipt_handle, queue_url, context) return @@ -431,7 +431,7 @@ async def subscribe_wildcard_topic(cls: Any, topic: str, queue_arn: str, queue_u return None - async def subscribe_topics(cls: Any, topic_arn_list: List, queue_arn: str, queue_url: str, context: Dict, queue_policy: Optional[Dict]=None) -> List: + async def subscribe_topics(cls: Any, topic_arn_list: List, queue_arn: str, queue_url: str, context: Dict, queue_policy: Optional[Dict] = None) -> List: if not cls.clients or not cls.clients.get('sns'): cls.create_client(cls, 'sns', context) client = cls.clients.get('sns') @@ -646,7 +646,7 @@ async def subscribe(cls: Any, obj: Any, context: Dict) -> Optional[Callable]: async def _subscribe() -> None: cls.close_waiter = asyncio.Future() - async def setup_queue(topic: str, func: Callable, queue_name: Optional[str]=None, competing_consumer: Optional[bool]=None) -> str: + async def setup_queue(topic: str, func: Callable, queue_name: Optional[str] = None, competing_consumer: Optional[bool] = None) -> str: _uuid = obj.uuid if queue_name and competing_consumer is False: diff --git a/tomodachi/transport/http.py b/tomodachi/transport/http.py index d4aef9225..354f3cb8f 100644 --- a/tomodachi/transport/http.py +++ b/tomodachi/transport/http.py @@ -31,7 +31,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @staticmethod - def colorize_status(text: Optional[Union[str, int]], status: Optional[Union[str, int, bool]]=False) -> str: + def colorize_status(text: Optional[Union[str, int]], status: Optional[Union[str, int, bool]] = False) -> str: if status is False: status = text status_code = str(status) if status else None @@ -56,7 +56,7 @@ def colorize_status(text: Optional[Union[str, int]], status: Optional[Union[str, return str(text) if text else '' - def handle_error(self, request: Any, status: int=500, exc: Any=None, message: Optional[str]=None) -> web.Response: + def handle_error(self, request: Any, status: int = 500, exc: Any = None, message: Optional[str] = None) -> web.Response: """Handle errors. Returns HTTP response with specific status code. Logs additional @@ -123,7 +123,7 @@ def __call__(self) -> RequestHandler: class DynamicResource(web_urldispatcher.DynamicResource): # type: ignore - def __init__(self, pattern: Any, *, name: Optional[str]=None) -> None: + def __init__(self, pattern: Any, *, name: Optional[str] = None) -> None: self._routes = [] # type: List self._name = name self._pattern = pattern @@ -131,7 +131,7 @@ def __init__(self, pattern: Any, *, name: Optional[str]=None) -> None: class Response(object): - def __init__(self, *, body: Optional[str]=None, status: int=200, reason: Optional[str]=None, headers: Optional[Union[Dict, CIMultiDict, CIMultiDictProxy]]=None, content_type: Optional[str]=None, charset: Optional[str]=None) -> None: + def __init__(self, *, body: Optional[str] = None, status: int = 200, reason: Optional[str] = None, headers: Optional[Union[Dict, CIMultiDict, CIMultiDictProxy]] = None, content_type: Optional[str] = None, charset: Optional[str] = None) -> None: if headers is None: headers = CIMultiDict() elif not isinstance(headers, (CIMultiDict, CIMultiDictProxy)): @@ -146,7 +146,7 @@ def __init__(self, *, body: Optional[str]=None, status: int=200, reason: Optiona self.missing_content_type = hdrs.CONTENT_TYPE not in headers and not content_type and not charset - def get_aiohttp_response(self, context: Dict, default_charset: Optional[str]=None, default_content_type: Optional[str]=None) -> web.Response: + def get_aiohttp_response(self, context: Dict, default_charset: Optional[str] = None, default_content_type: Optional[str] = None) -> web.Response: if self.missing_content_type: self.charset = default_charset self.content_type = default_content_type diff --git a/tomodachi/transport/schedule.py b/tomodachi/transport/schedule.py index 26fe310b3..58017fb73 100644 --- a/tomodachi/transport/schedule.py +++ b/tomodachi/transport/schedule.py @@ -13,7 +13,7 @@ class Scheduler(Invoker): close_waiter = None - async def schedule_handler(cls: Any, obj: Any, context: Dict, func: Any, interval: Optional[Union[str, int]]=None, timestamp: Optional[str]=None, timezone: Optional[str]=None, immediately: Optional[bool]=False) -> Any: + async def schedule_handler(cls: Any, obj: Any, context: Dict, func: Any, interval: Optional[Union[str, int]] = None, timestamp: Optional[str] = None, timezone: Optional[str] = None, immediately: Optional[bool] = False) -> Any: async def handler() -> None: values = inspect.getfullargspec(func) kwargs = {k: values.defaults[i] for i, k in enumerate(values.args[len(values.args) - len(values.defaults):])} if values.defaults else {} @@ -38,7 +38,7 @@ def _func(cls: Any, obj: Any, context: Dict, func: Any) -> Any: return _func @classmethod - def next_call_at(cls, current_time: float, interval: Optional[Union[str, int]]=None, timestamp: Optional[str]=None, timezone: Optional[str]=None) -> int: + def next_call_at(cls, current_time: float, interval: Optional[Union[str, int]] = None, timestamp: Optional[str] = None, timezone: Optional[str] = None) -> int: if not timezone: tz = tzlocal.get_localzone() else: @@ -145,7 +145,7 @@ def next_call_at(cls, current_time: float, interval: Optional[Union[str, int]]=N return int(current_time + 60 * 60 * 24 * 365 * 100) - def get_timezone(cls: Any, timezone: Optional[str]=None) -> Optional[str]: + def get_timezone(cls: Any, timezone: Optional[str] = None) -> Optional[str]: if timezone: tz_aliases = { ('+00:00', '-00:00', '00:00', '0000', 'GMT +0000', 'GMT +00:00', 'GMT -00', 'GMT +00', 'GMT -0', 'GMT +0'): 'GMT0', @@ -185,7 +185,7 @@ def get_timezone(cls: Any, timezone: Optional[str]=None) -> Optional[str]: return timezone - async def start_schedule_loop(cls: Any, obj: Any, context: Dict, handler: Callable, func: Callable, interval: Optional[Union[str, int]]=None, timestamp: Optional[str]=None, timezone: Optional[str]=None, immediately: Optional[bool]=False) -> None: + async def start_schedule_loop(cls: Any, obj: Any, context: Dict, handler: Callable, func: Callable, interval: Optional[Union[str, int]] = None, timestamp: Optional[str] = None, timezone: Optional[str] = None, immediately: Optional[bool] = False) -> None: timezone = cls.get_timezone(timezone) if not cls.close_waiter: diff --git a/tomodachi/validation/validation.py b/tomodachi/validation/validation.py index 3c6eea886..ae259bd11 100644 --- a/tomodachi/validation/validation.py +++ b/tomodachi/validation/validation.py @@ -26,7 +26,7 @@ def validate_field_regex(value: str, pattern_str: str) -> None: raise RegexMissmatchException(value=value, pattern=pattern_str) -def validate_field_length(obj: Union[List, str], min_length: int=-1, max_length: int=-1) -> None: +def validate_field_length(obj: Union[List, str], min_length: int = -1, max_length: int = -1) -> None: if min_length != -1: if len(obj) < min_length: raise TooSmallException(obj=obj, min_length=min_length) diff --git a/tomodachi/watcher.py b/tomodachi/watcher.py index 41aa0c524..45df06ef6 100644 --- a/tomodachi/watcher.py +++ b/tomodachi/watcher.py @@ -6,7 +6,7 @@ class Watcher(object): - def __init__(self, root: Optional[List]=None, configuration: Optional[Dict]=None) -> None: + def __init__(self, root: Optional[List] = None, configuration: Optional[Dict] = None) -> None: self.watched_files = {} # type: Dict[str, float] self.root = [] # type: List[str] self.ignored_dirs = ['__pycache__', '.git', '.svn', '__ignored__', '__temporary__', '__tmp__'] @@ -29,7 +29,7 @@ def __init__(self, root: Optional[List]=None, configuration: Optional[Dict]=None self.update_watched_files() - def update_watched_files(self, reindex: bool=False) -> Dict: + def update_watched_files(self, reindex: bool = False) -> Dict: watched_files = {} if not self.watched_files or reindex: for r in self.root: @@ -56,7 +56,7 @@ def update_watched_files(self, reindex: bool=False) -> Dict: self.watched_files = watched_files return {} - async def watch(self, loop: asyncio.AbstractEventLoop=None, callback_func: Optional[Callable]=None) -> Any: + async def watch(self, loop: asyncio.AbstractEventLoop = None, callback_func: Optional[Callable] = None) -> Any: _loop = asyncio.get_event_loop() if not loop else loop # type: Any async def _watch_loop() -> None: