From e7e953b4ac590497e83c2ade5a234c33bdeeadf1 Mon Sep 17 00:00:00 2001 From: slowy07 Date: Sun, 1 Aug 2021 20:34:59 +0700 Subject: [PATCH] fix: lambda function should not in, indentation, and lint issue --- scripts/fixup_firestore_admin_v1_keywords.py | 23 ++++++------- scripts/fixup_firestore_v1_keywords.py | 35 ++++++++++---------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/scripts/fixup_firestore_admin_v1_keywords.py b/scripts/fixup_firestore_admin_v1_keywords.py index bd5f8dd368..a1dc19d5ad 100644 --- a/scripts/fixup_firestore_admin_v1_keywords.py +++ b/scripts/fixup_firestore_admin_v1_keywords.py @@ -22,7 +22,6 @@ raise ImportError('Run `python -m pip install "libcst >= 0.2.5"` to install libcst.') - import pathlib import sys from typing import (Any, Callable, Dict, List, Sequence, Tuple) @@ -45,15 +44,15 @@ def partition( class firestore_adminCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_index': ('parent', 'index', ), - 'delete_index': ('name', ), - 'export_documents': ('name', 'collection_ids', 'output_uri_prefix', ), - 'get_field': ('name', ), - 'get_index': ('name', ), - 'import_documents': ('name', 'collection_ids', 'input_uri_prefix', ), - 'list_fields': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_indexes': ('parent', 'filter', 'page_size', 'page_token', ), - 'update_field': ('field', 'update_mask', ), + 'create_index': ('parent', 'index', ), + 'delete_index': ('name', ), + 'export_documents': ('name', 'collection_ids', 'output_uri_prefix', ), + 'get_field': ('name', ), + 'get_index': ('name', ), + 'import_documents': ('name', 'collection_ids', 'input_uri_prefix', ), + 'list_fields': ('parent', 'filter', 'page_size', 'page_token', ), + 'list_indexes': ('parent', 'filter', 'page_size', 'page_token', ), + 'update_field': ('field', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -72,7 +71,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) @@ -84,7 +83,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) + cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/scripts/fixup_firestore_v1_keywords.py b/scripts/fixup_firestore_v1_keywords.py index 8f71f6285a..0b91081e05 100644 --- a/scripts/fixup_firestore_v1_keywords.py +++ b/scripts/fixup_firestore_v1_keywords.py @@ -22,7 +22,6 @@ raise ImportError('Run `python -m pip install "libcst >= 0.2.5"` to install libcst.') - import pathlib import sys from typing import (Any, Callable, Dict, List, Sequence, Tuple) @@ -45,21 +44,21 @@ def partition( class firestoreCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'batch_get_documents': ('database', 'documents', 'mask', 'transaction', 'new_transaction', 'read_time', ), - 'batch_write': ('database', 'writes', 'labels', ), - 'begin_transaction': ('database', 'options', ), - 'commit': ('database', 'writes', 'transaction', ), - 'create_document': ('parent', 'collection_id', 'document', 'document_id', 'mask', ), - 'delete_document': ('name', 'current_document', ), - 'get_document': ('name', 'mask', 'transaction', 'read_time', ), - 'list_collection_ids': ('parent', 'page_size', 'page_token', ), - 'list_documents': ('parent', 'collection_id', 'page_size', 'page_token', 'order_by', 'mask', 'transaction', 'read_time', 'show_missing', ), - 'listen': ('database', 'add_target', 'remove_target', 'labels', ), - 'partition_query': ('parent', 'structured_query', 'partition_count', 'page_token', 'page_size', ), - 'rollback': ('database', 'transaction', ), - 'run_query': ('parent', 'structured_query', 'transaction', 'new_transaction', 'read_time', ), - 'update_document': ('document', 'update_mask', 'mask', 'current_document', ), - 'write': ('database', 'stream_id', 'writes', 'stream_token', 'labels', ), + 'batch_get_documents': ('database', 'documents', 'mask', 'transaction', 'new_transaction', 'read_time', ), + 'batch_write': ('database', 'writes', 'labels', ), + 'begin_transaction': ('database', 'options', ), + 'commit': ('database', 'writes', 'transaction', ), + 'create_document': ('parent', 'collection_id', 'document', 'document_id', 'mask', ), + 'delete_document': ('name', 'current_document', ), + 'get_document': ('name', 'mask', 'transaction', 'read_time', ), + 'list_collection_ids': ('parent', 'page_size', 'page_token', ), + 'list_documents': ('parent', 'collection_id', 'page_size', 'page_token', 'order_by', 'mask', 'transaction', 'read_time', 'show_missing', ), + 'listen': ('database', 'add_target', 'remove_target', 'labels', ), + 'partition_query': ('parent', 'structured_query', 'partition_count', 'page_token', 'page_size', ), + 'rollback': ('database', 'transaction', ), + 'run_query': ('parent', 'structured_query', 'transaction', 'new_transaction', 'read_time', ), + 'update_document': ('document', 'update_mask', 'mask', 'current_document', ), + 'write': ('database', 'stream_id', 'writes', 'stream_token', 'labels', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -78,7 +77,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) @@ -90,7 +89,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) + cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that