diff --git a/lib/simplediff/__init__.py b/lib/simplediff/__init__.py
index 64ec64b4..a1866ba1 100644
--- a/lib/simplediff/__init__.py
+++ b/lib/simplediff/__init__.py
@@ -13,8 +13,18 @@ May be used and distributed under the zlib/libpng license
 __all__ = ['diff', 'string_diff', 'html_diff']
 __version__ = '1.0'
 
-
-def diff(old, new):
+from typing import (
+    Callable,
+    Dict,
+    List,
+    Sequence,
+    Tuple,
+    TypeVar,
+)
+
+T = TypeVar('T', str, int)
+
+def diff(old: List[T], new: List[T]) -> List[Tuple[str, List[T]]]:
     '''
     Find the differences between two lists. Returns a list of pairs, where the
     first value is in ['+','-','='] and represents an insertion, deletion, or
@@ -53,7 +63,7 @@ def diff(old, new):
     '''
 
     # Create a map from old values to their indices
-    old_index_map = dict()
+    old_index_map: Dict[T, List[int]] = dict()
     for i, val in enumerate(old):
         old_index_map.setdefault(val,list()).append(i)
 
@@ -73,7 +83,7 @@ def diff(old, new):
     # seen so far (`sub_length`), we update the largest substring
     # to the overlapping strings.
 
-    overlap = dict()
+    overlap: Dict[int, int] = dict()
     # `sub_start_old` is the index of the beginning of the largest overlapping
     # substring in the old list. `sub_start_new` is the index of the beginning
     # of the same substring in the new list. `sub_length` is the length that
@@ -85,7 +95,7 @@ def diff(old, new):
     sub_length = 0
 
     for inew, val in enumerate(new):
-        _overlap = dict()
+        _overlap: Dict[int, int] = dict()
         for iold in old_index_map.get(val,list()):
             # now we are considering all values of iold such that
             # `old[iold] == new[inew]`.
@@ -110,7 +120,7 @@ def diff(old, new):
                        new[sub_start_new + sub_length : ])
 
 
-def string_diff(old, new):
+def string_diff(old: str, new: str) -> List[Tuple[str, List[str]]]:
     '''
     Returns the difference between the old and new strings when split on
     whitespace. Considers punctuation a part of the word
@@ -139,7 +149,7 @@ def string_diff(old, new):
     return diff(old.split(), new.split())
 
 
-def html_diff(old, new):
+def html_diff(old: str, new: str) -> str:
     '''
     Returns the difference between two strings (as in stringDiff) in
     HTML format. HTML code in the strings is NOT escaped, so you
@@ -160,13 +170,14 @@ def html_diff(old, new):
         >>> html_diff('The quick brown fox', 'The fast blue fox')
         'The <del>quick brown</del> <ins>fast blue</ins> fox'
     '''
-    con = {'=': (lambda x: x),
+    con: Dict[str, Callable[[str], str]] = {
+           '=': (lambda x: x),
            '+': (lambda x: "<ins>" + x + "</ins>"),
            '-': (lambda x: "<del>" + x + "</del>")}
     return " ".join([(con[a])(" ".join(b)) for a, b in string_diff(old, new)])
 
 
-def check_diff(old, new):
+def check_diff(old: Sequence[str], new: Sequence[str]) -> None:
     '''
     This tests that diffs returned by `diff` are valid. You probably won't
     want to use this function, but it's provided for documentation and
