pylint clean

This commit is contained in:
Luke Hoban 2020-01-03 14:21:50 -08:00 committed by Pat Gavlin
parent 5eda91bb9e
commit 9d6edeac1c
4 changed files with 22 additions and 24 deletions

View file

@ -18,4 +18,4 @@ The remote proxy implementation of the Pulumi Python SDK.
from .remote import (
ProxyComponentResource,
)
)

View file

@ -12,20 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
import os
from subprocess import Popen
import time
from typing import Callable, Any, Dict, List, Optional
import grpc
from .. import ComponentResource, CustomResource, Output, InvokeOptions, ResourceOptions, log, Input, Inputs, Resource
from ..runtime.proto import runtime_pb2, runtime_pb2_grpc
from ..runtime.rpc import deserialize_properties, serialize_properties
from ..runtime.settings import SETTINGS
import asyncio
import grpc
import os
from subprocess import Popen
import time
from typing import Callable, Any, Dict, List, Optional
def spawnServer(library_path: str):
p = Popen(["node", "-e", "require('@pulumi/pulumi/remote/server')"], cwd=library_path, env={
Popen(["node", "-e", "require('@pulumi/pulumi/remote/server')"], cwd=library_path, env={
**os.environ,
'PULUMI_NODEJS_PROJECT': SETTINGS.project,
'PULUMI_NODEJS_STACK': SETTINGS.stack,
@ -58,11 +57,11 @@ def get_server(library_path: str) -> runtime_pb2_grpc.RuntimeStub:
# return d
async def construct(
libraryPath: str,
resource: str,
name: str,
args: Any,
opts: ResourceOptions) -> Any:
libraryPath: str,
resource: str,
name: str,
args: Any,
_opts: ResourceOptions) -> Any:
property_dependencies_resources: Dict[str, List[Resource]] = {}
args_struct = await serialize_properties(args, property_dependencies_resources)
# TODO - support opts serialization
@ -82,14 +81,14 @@ class ProxyComponentResource(ComponentResource):
"""
Abstract base class for proxies around component resources.
"""
def __init__(__self__,
def __init__(self,
t: str,
name: str,
library_path: str,
library_name: str,
inputs: Inputs,
outputs: Dict[str, None],
opts: Optional[ResourceOptions]=None) -> None:
opts: Optional[ResourceOptions] = None) -> None:
if opts is None or opts.urn is None:
async def do_construct():
r = await construct(library_path, library_name, name, inputs, opts)

View file

@ -293,7 +293,6 @@ def _get_resource(res: 'Resource', ty: str, name: str, custom: bool, props: 'Inp
"Cannot get resource whose options are lacking a URN value")
log.debug(f"registering resource: ty={ty}, name={name}, custom={custom}")
monitor = settings.get_monitor()
# Prepare the resource.
@ -340,7 +339,7 @@ def _get_resource(res: 'Resource', ty: str, name: str, custom: bool, props: 'Inp
async def do_get():
try:
log.debug(f"preparing get: ty={ty}, name={name}, urn={urn}")
resolver = await prepare_resource(res, ty, custom, props, opts)
_ = await prepare_resource(res, ty, custom, props, opts)
# Resolve the URN that we were given. Note that we are explicitly discarding the list of
# dependencies returned to us from "serialize_property" (the second argument). This is
@ -349,8 +348,8 @@ def _get_resource(res: 'Resource', ty: str, name: str, custom: bool, props: 'Inp
# dependency. TODO: This this actually true for "get"?
resolved_urn = await rpc.serialize_property(urn, [])
log.debug(f"get prepared: ty={ty}, name={name}, urn={urn}")
resp = await invoke("pulumi:pulumi:readStackResource", { "urn": resolved_urn })
resp = await invoke("pulumi:pulumi:readStackResource", {"urn": resolved_urn})
except Exception as exn:
log.debug(
f"exception when preparing or executing rpc: {traceback.format_exc()}")
@ -364,7 +363,7 @@ def _get_resource(res: 'Resource', ty: str, name: str, custom: bool, props: 'Inp
resolve_urn(resp["urn"])
if custom:
resolve_id(resp["outputs"]["id"], True, None) # Get IDs are always known.
await rpc.resolve_properties(res, resolvers, resp["outputs"])
await rpc.resolve_properties(resolvers, resp["outputs"])
asyncio.ensure_future(RPC_MANAGER.do_rpc("get resource", do_get)())

View file

@ -250,7 +250,7 @@ def deserialize_properties(props_struct: struct_pb2.Struct, keep_unknowns: Optio
proxy_constructor = PROXY_CONSTRUCTORS.get(typ, None)
if proxy_constructor is not None:
urn_name = urn_parts[3]
return proxy_constructor(urn_name, { 'urn': urn })
return proxy_constructor(urn_name, {"urn": urn})
print(f"Saw valid URN {urn} during deserialization, but no proxy constructor is registered for type {typ}.")
return urn
@ -441,9 +441,9 @@ async def resolve_outputs(res: 'Resource',
# the user.
all_properties[translated_key] = translate_output_properties(res, deserialize_property(value))
await resolve_properties(res, resolvers, all_properties)
await resolve_properties(resolvers, all_properties)
async def resolve_properties(res: 'Resource', resolvers: Dict[str, Resolver], all_properties:Dict[str, Any]):
async def resolve_properties(resolvers: Dict[str, Resolver], all_properties: Dict[str, Any]):
for key, value in all_properties.items():
# Skip "id" and "urn", since we handle those specially.