Skip to content

Commit

Permalink
update black & pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Jul 24, 2021
1 parent bd20fb6 commit 6963147
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 60 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ check:
--search-path stubs \
--typeshed `python3 -c 'import sys, site, os; print(next(p for p in (os.path.join(dir,"lib/pyre_check/typeshed") for dir in (sys.prefix,site.getuserbase())) if os.path.isdir(p)))'` \
--show-parse-errors check
# no-member disabled due to https://github.com/PyCQA/pylint/issues/3137
pylint -j `python3 -c 'import multiprocessing as mp; print(mp.cpu_count())'` --errors-only WDL -d no-member
pylint -j `python3 -c 'import multiprocessing as mp; print(mp.cpu_count())'` --errors-only WDL
flake8 WDL

check_check:
Expand All @@ -54,8 +53,7 @@ check_check:
# uses black to rewrite source files!
pretty:
black --line-length 100 --target-version py36 WDL/
# no-member disabled due to https://github.com/PyCQA/pylint/issues/3137
pylint -d cyclic-import,empty-docstring,missing-docstring,invalid-name,bad-continuation --exit-zero WDL -d no-member
pylint -d cyclic-import,empty-docstring,missing-docstring,invalid-name,bad-continuation --exit-zero WDL

# for use in CI: complain if source code isn't at a fixed point for black
sopretty:
Expand Down
2 changes: 1 addition & 1 deletion WDL/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ def run_self_test(**kwargs):
if kwargs["log_json"]:
argv.append("--log-json")
try:
outputs = main(argv)["outputs"]
outputs = main(argv)["outputs"] # pylint: disable=E1136
assert len(outputs["hello_caller.messages"]) == 2
assert outputs["hello_caller.messages"][0].rstrip() == "Hello, Alyssa P. Hacker!"
assert outputs["hello_caller.messages"][1].rstrip() == "Hello, Ben Bitdiddle!"
Expand Down
5 changes: 3 additions & 2 deletions WDL/Error.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def __init__(


class _MultiContext:
""
""""""

_exceptions: List[Union[ValidationError, MultipleValidationErrors]]

def __init__(self) -> None:
Expand All @@ -278,7 +279,7 @@ def maybe_raise(self) -> None:

@contextmanager
def multi_context() -> Generator[_MultiContext, None, None]:
""
""""""
# Context manager to assist with catching and propagating multiple
# validation/typechecking errors
#
Expand Down
28 changes: 14 additions & 14 deletions WDL/Expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Boolean()

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Boolean:
""
""""""
return Value.Boolean(self.value)


Expand All @@ -185,7 +185,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Int()

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Int:
""
""""""
return Value.Int(self.value)


Expand Down Expand Up @@ -215,7 +215,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Float()

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Float:
""
""""""
return Value.Float(self.value)


Expand All @@ -242,7 +242,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Any(null=True)

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Null:
""
""""""
return Value.Null()


Expand Down Expand Up @@ -321,7 +321,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.String()

def _eval_impl(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.String:
""
""""""
v = self.expr.eval(env, stdlib)
if isinstance(v, Value.Null):
if "default" in self.options:
Expand Down Expand Up @@ -399,11 +399,11 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.String()

def typecheck(self, expected: Optional[Type.Base]) -> Base:
""
""""""
return super().typecheck(expected) # pyre-ignore

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.String:
""
""""""
ans = []
for part in self.parts:
if isinstance(part, Placeholder):
Expand Down Expand Up @@ -466,14 +466,14 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Array(item_type, optional=False, nonempty=True)

def typecheck(self, expected: Optional[Type.Base]) -> Base:
""
""""""
if not self.items and isinstance(expected, Type.Array):
# the literal empty array satisfies any array type
return self
return super().typecheck(expected) # pyre-ignore

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Array:
""
""""""
assert isinstance(self.type, Type.Array)
return Value.Array(
self.type.item_type,
Expand Down Expand Up @@ -528,7 +528,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Pair(self.left.type, self.right.type)

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Base:
""
""""""
assert isinstance(self.type, Type.Pair)
lv = self.left.eval(env, stdlib)
rv = self.right.eval(env, stdlib)
Expand Down Expand Up @@ -602,7 +602,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return Type.Map((kty, vty), literal_keys=literal_keys)

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Base:
""
""""""
assert isinstance(self.type, Type.Map)
keystrs = set()
eitems = []
Expand Down Expand Up @@ -785,7 +785,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return ty

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Base:
""
""""""
if self.condition.eval(env, stdlib).expect(Type.Boolean()).value:
ans = self.consequent.eval(env, stdlib)
else:
Expand Down Expand Up @@ -845,7 +845,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return ans

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Base:
""
""""""
return env[self.name]

@property
Expand Down Expand Up @@ -1120,7 +1120,7 @@ def _infer_type(self, type_env: Env.Bindings[Type.Base]) -> Type.Base:
return f.infer_type(self)

def _eval(self, env: Env.Bindings[Value.Base], stdlib: StdLib.Base) -> Value.Base:
""
""""""

f = getattr(stdlib, self.function_name, None)
assert isinstance(f, StdLib.Function)
Expand Down
18 changes: 9 additions & 9 deletions WDL/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __str__(self) -> str:

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
if self.expr:
yield self.expr

Expand Down Expand Up @@ -353,7 +353,7 @@ def effective_outputs(self) -> Env.Bindings[Type.Base]:

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
for d in self.inputs or []:
yield d
for d in self.postinputs:
Expand Down Expand Up @@ -527,7 +527,7 @@ def __init__(

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
for _, ex in self.inputs.items():
yield ex

Expand Down Expand Up @@ -720,7 +720,7 @@ def _workflow_node_dependencies(self) -> Iterable[str]:

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
# section & referee are NOT 'children' of Gather
return []

Expand Down Expand Up @@ -788,7 +788,7 @@ def __init__(self, body: List[WorkflowNode], *args, **kwargs):

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
for elt in self.body:
yield elt
for elt in self.gathers.values():
Expand Down Expand Up @@ -827,7 +827,7 @@ def __init__(

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
yield self.expr
yield from super().children

Expand Down Expand Up @@ -896,7 +896,7 @@ def __init__(self, pos: SourcePosition, expr: Expr.Base, body: List[WorkflowNode

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
yield self.expr
yield from super().children

Expand Down Expand Up @@ -1100,7 +1100,7 @@ def effective_outputs(self) -> Env.Bindings[Type.Base]:

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
for d in self.inputs or []:
yield d
for elt in self.body:
Expand Down Expand Up @@ -1407,7 +1407,7 @@ def __init__(

@property
def children(self) -> Iterable[SourceNode]:
""
""""""
for imp in self.imports:
if imp.doc:
yield imp.doc
Expand Down
23 changes: 12 additions & 11 deletions WDL/Type.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, optional: bool = False) -> None:
self._optional = optional

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, String):
return True
return super().coerces(rhs, check_quant)
Expand All @@ -146,7 +146,7 @@ def __init__(self, optional: bool = False) -> None:
self._optional = optional

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, String):
return True
return super().coerces(rhs, check_quant)
Expand All @@ -157,7 +157,7 @@ def __init__(self, optional: bool = False) -> None:
self._optional = optional

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, Float):
return self._check_optional(rhs, check_quant)
if isinstance(rhs, String):
Expand All @@ -170,7 +170,7 @@ def __init__(self, optional: bool = False) -> None:
self._optional = optional

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, String):
return True
return super().coerces(rhs, check_quant)
Expand All @@ -181,7 +181,7 @@ def __init__(self, optional: bool = False) -> None:
self._optional = optional

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, String):
return True
return super().coerces(rhs, check_quant)
Expand All @@ -192,7 +192,7 @@ def __init__(self, optional: bool = False) -> None:
self._optional = optional

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, (File, Directory, Int, Float)):
return self._check_optional(rhs, check_quant)
return super().coerces(rhs, check_quant)
Expand Down Expand Up @@ -242,7 +242,7 @@ def parameters(self) -> Iterable[Base]:
yield self.item_type

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, Array):
return self.item_type.coerces(rhs.item_type, check_quant) and self._check_optional(
rhs, check_quant
Expand Down Expand Up @@ -308,7 +308,7 @@ def parameters(self) -> Iterable[Base]:
yield self.item_type[1]

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, Map):
return (
self.item_type[0].coerces(rhs.item_type[0], check_quant)
Expand Down Expand Up @@ -378,7 +378,7 @@ def parameters(self) -> Iterable[Base]:
yield self.right_type

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, Pair):
return (
self.left_type.coerces(rhs.left_type, check_quant)
Expand Down Expand Up @@ -424,7 +424,7 @@ def __str__(self) -> str:
return self.type_name + ("?" if self.optional else "")

def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
""
""""""
if isinstance(rhs, StructInstance):
return self.type_id == rhs.type_id and self._check_optional(rhs, check_quant)
if isinstance(rhs, Any):
Expand Down Expand Up @@ -463,7 +463,8 @@ def _struct_type_id(members: Dict[str, Base]) -> str:


class Object(Base):
""
""""""

# In WDL 1.0, struct instances are created by coercion from object
# literals. So we need something to represent the type of an object literal
# (a bag of keys and values) prior to its coercion to a named struct type.
Expand Down
Loading

0 comments on commit 6963147

Please sign in to comment.