Skip to content

Commit

Permalink
Add type hints (#3701)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanxu18 authored Jul 9, 2021
1 parent 921d3f4 commit 70359d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion contrib/admin/mypy-with-ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def main():
'src/toil/deferred.py',
'src/toil/version.py',
'src/toil/wdl/utils.py',
'src/toil/wdl/wdl_types.py',
'src/toil/wdl/wdl_synthesis.py',
'src/toil/wdl/wdl_analysis.py',
'src/toil/wdl/wdl_functions.py',
Expand Down
22 changes: 11 additions & 11 deletions src/toil/wdl/wdl_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC
from typing import Any
from typing import Any, Dict, Optional

from toil.job import Promise

Expand Down Expand Up @@ -27,7 +27,7 @@ def name(self) -> str:
raise NotImplementedError

@property
def default_value(self):
def default_value(self) -> Optional[str]:
"""
Default value if optional.
"""
Expand Down Expand Up @@ -55,13 +55,13 @@ def create(self, value: Any, output: bool = False) -> Any:
def _create(self, value: Any) -> Any:
raise NotImplementedError

def __eq__(self, other):
def __eq__(self, other: Any) -> bool:
return self.name.__eq__(other)

def __str__(self):
def __str__(self) -> str:
return self.name.__str__()

def __repr__(self):
def __repr__(self) -> str:
return self.name.__repr__()


Expand All @@ -80,7 +80,7 @@ def name(self) -> str:
return 'String'

@property
def default_value(self):
def default_value(self) -> str:
return ''

def _create(self, value: Any) -> Any:
Expand Down Expand Up @@ -128,7 +128,7 @@ def name(self) -> str:
return 'File'

@property
def default_value(self):
def default_value(self) -> str:
return ''

def _create(self, value: Any) -> Any:
Expand Down Expand Up @@ -210,7 +210,7 @@ class WDLFile:
"""
Represents a WDL File.
"""
def __init__(self, file_path, file_name=None, imported=False):
def __init__(self, file_path: str, file_name: Optional[str] = None, imported: bool = False):
"""
:param file_path: Path to file.
:param file_name: Optional. Preserved file name.
Expand All @@ -232,13 +232,13 @@ def __init__(self, left: Any, right: Any):
self.left = left
self.right = right

def to_dict(self):
def to_dict(self) -> Dict[str, Any]:
return {'left': self.left, 'right': self.right}

def __eq__(self, other):
def __eq__(self, other: Any) -> Any:
if not isinstance(other, WDLPair):
return False
return self.left == other.left and self.right == other.right

def __repr__(self):
def __repr__(self) -> str:
return str(self.to_dict())

0 comments on commit 70359d1

Please sign in to comment.