Index: sasmodels/compare.py
===================================================================
--- sasmodels/compare.py	(revision bd49c79233b87a14ec27cb88be3fabcb94f8d1bf)
+++ sasmodels/compare.py	(revision b32dafd2b778081295c58e5d7727689b2b42fc68)
@@ -184,5 +184,5 @@
         pass
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, exc_type, exc_value, traceback):
         # type: (Any, BaseException, Any) -> None
         # TODO: better typing for __exit__ method
@@ -436,5 +436,5 @@
                 smearer.model = model[0]
                 return smearer.get_value()
-            theory = lambda: _call_smearer()
+            theory = _call_smearer
         else:
             theory = lambda: model[0].evalDistribution([data.qx_data[index],
@@ -503,5 +503,5 @@
     return calculator
 
-def time_calculation(calculator, pars, Nevals=1):
+def time_calculation(calculator, pars, evals=1):
     # type: (Calculator, ParameterSet, int) -> Tuple[np.ndarray, float]
     """
@@ -512,12 +512,12 @@
     """
     # initialize the code so time is more accurate
-    if Nevals > 1:
+    if evals > 1:
         calculator(**suppress_pd(pars))
     toc = tic()
     # make sure there is at least one eval
     value = calculator(**pars)
-    for _ in range(Nevals-1):
+    for _ in range(evals-1):
         value = calculator(**pars)
-    average_time = toc()*1000./Nevals
+    average_time = toc()*1000. / evals
     #print("I(q)",value)
     return value, average_time
@@ -591,18 +591,18 @@
     parameters.
     """
-    Nbase, Ncomp = opts['n1'], opts['n2']
+    n_base, n_comp = opts['n1'], opts['n2']
     pars = opts['pars']
     data = opts['data']
 
     # silence the linter
-    base = opts['engines'][0] if Nbase else None
-    comp = opts['engines'][1] if Ncomp else None
+    base = opts['engines'][0] if n_base else None
+    comp = opts['engines'][1] if n_comp else None
     base_time = comp_time = None
     base_value = comp_value = resid = relerr = None
 
     # Base calculation
-    if Nbase > 0:
+    if n_base > 0:
         try:
-            base_raw, base_time = time_calculation(base, pars, Nbase)
+            base_raw, base_time = time_calculation(base, pars, n_base)
             base_value = np.ma.masked_invalid(base_raw)
             print("%s t=%.2f ms, intensity=%.0f"
@@ -611,10 +611,10 @@
         except ImportError:
             traceback.print_exc()
-            Nbase = 0
+            n_base = 0
 
     # Comparison calculation
-    if Ncomp > 0:
+    if n_comp > 0:
         try:
-            comp_raw, comp_time = time_calculation(comp, pars, Ncomp)
+            comp_raw, comp_time = time_calculation(comp, pars, n_comp)
             comp_value = np.ma.masked_invalid(comp_raw)
             print("%s t=%.2f ms, intensity=%.0f"
@@ -623,10 +623,10 @@
         except ImportError:
             traceback.print_exc()
-            Ncomp = 0
+            n_comp = 0
 
     # Compare, but only if computing both forms
-    if Nbase > 0 and Ncomp > 0:
+    if n_base > 0 and n_comp > 0:
         resid = (base_value - comp_value)
-        relerr = resid/np.where(comp_value!=0., abs(comp_value), 1.0)
+        relerr = resid/np.where(comp_value != 0., abs(comp_value), 1.0)
         _print_stats("|%s-%s|"
                      % (base.engine, comp.engine) + (" "*(3+len(comp.engine))),
@@ -642,23 +642,23 @@
     if limits is None:
         vmin, vmax = np.Inf, -np.Inf
-        if Nbase > 0:
+        if n_base > 0:
             vmin = min(vmin, base_value.min())
             vmax = max(vmax, base_value.max())
-        if Ncomp > 0:
+        if n_comp > 0:
             vmin = min(vmin, comp_value.min())
             vmax = max(vmax, comp_value.max())
         limits = vmin, vmax
 
-    if Nbase > 0:
-        if Ncomp > 0: plt.subplot(131)
+    if n_base > 0:
+        if n_comp > 0: plt.subplot(131)
         plot_theory(data, base_value, view=view, use_data=False, limits=limits)
         plt.title("%s t=%.2f ms"%(base.engine, base_time))
         #cbar_title = "log I"
-    if Ncomp > 0:
-        if Nbase > 0: plt.subplot(132)
+    if n_comp > 0:
+        if n_base > 0: plt.subplot(132)
         plot_theory(data, comp_value, view=view, use_data=False, limits=limits)
         plt.title("%s t=%.2f ms"%(comp.engine, comp_time))
         #cbar_title = "log I"
-    if Ncomp > 0 and Nbase > 0:
+    if n_comp > 0 and n_base > 0:
         plt.subplot(133)
         if not opts['rel_err']:
@@ -678,5 +678,5 @@
     fig.suptitle(opts['name'])
 
-    if Ncomp > 0 and Nbase > 0 and '-hist' in opts:
+    if n_comp > 0 and n_base > 0 and '-hist' in opts:
         plt.figure()
         v = relerr
@@ -732,5 +732,5 @@
     ]
 
-def columnize(L, indent="", width=79):
+def columnize(items, indent="", width=79):
     # type: (List[str], str, int) -> str
     """
@@ -739,9 +739,9 @@
     Returns a string with carriage returns ready for printing.
     """
-    column_width = max(len(w) for w in L) + 1
+    column_width = max(len(w) for w in items) + 1
     num_columns = (width - len(indent)) // column_width
-    num_rows = len(L) // num_columns
-    L = L + [""] * (num_rows*num_columns - len(L))
-    columns = [L[k*num_rows:(k+1)*num_rows] for k in range(num_columns)]
+    num_rows = len(items) // num_columns
+    items = items + [""] * (num_rows * num_columns - len(items))
+    columns = [items[k*num_rows:(k+1)*num_rows] for k in range(num_columns)]
     lines = [" ".join("%-*s"%(column_width, entry) for entry in row)
              for row in zip(*columns)]
@@ -766,7 +766,8 @@
         for ext, val in parts:
             if p.length > 1:
-                dict(("%s%d%s"%(p.id,k,ext), val) for k in range(1, p.length+1))
+                dict(("%s%d%s" % (p.id, k, ext), val)
+                     for k in range(1, p.length+1))
             else:
-                pars[p.id+ext] = val
+                pars[p.id + ext] = val
 
     # Plug in values given in demo
@@ -887,5 +888,5 @@
     n1 = int(args[1]) if len(args) > 1 else 1
     n2 = int(args[2]) if len(args) > 2 else 1
-    use_sasview = any(engine=='sasview' and count>0
+    use_sasview = any(engine == 'sasview' and count > 0
                       for engine, count in zip(engines, [n1, n2]))
 
Index: sasmodels/rst2html.py
===================================================================
--- sasmodels/rst2html.py	(revision 7722b4a0a0bc4e68b2ec1c423a375f941b636743)
+++ sasmodels/rst2html.py	(revision b32dafd2b778081295c58e5d7727689b2b42fc68)
@@ -1,7 +1,7 @@
-"""
+r"""
 Convert a restructured text document to html.
 
 Inline math markup can uses the *math* directive, or it can use latex
-style *\$expression\$*.  Math can be rendered using simple html and 
+style *\$expression\$*.  Math can be rendered using simple html and
 unicode, or with mathjax.
 """
@@ -41,7 +41,7 @@
     # others don't work properly with math_output!
     if math_output == "mathjax":
-        settings = { "math_output": math_output }
+        settings = {"math_output": math_output}
     else:
-        settings = { "math-output": math_output }
+        settings = {"math-output": math_output}
 
     # math2html and mathml do not support \frac12
@@ -89,5 +89,5 @@
     Convert dollar signs to inline math markup in rst.
     """
-    content = _dollar.sub(r":math:`\1`",content)
+    content = _dollar.sub(r":math:`\1`", content)
     content = _notdollar.sub("$", content)
     return content
@@ -95,23 +95,26 @@
 
 def test_dollar():
-    assert replace_dollar(u"no dollar")==u"no dollar"
-    assert replace_dollar(u"$only$")==u":math:`only`"
-    assert replace_dollar(u"$first$ is good")==u":math:`first` is good"
-    assert replace_dollar(u"so is $last$")==u"so is :math:`last`"
-    assert replace_dollar(u"and $mid$ too")==u"and :math:`mid` too"
-    assert replace_dollar(u"$first$, $mid$, $last$")==u":math:`first`, :math:`mid`, :math:`last`"
-    assert replace_dollar(u"dollar\$ escape")==u"dollar$ escape"
-    assert replace_dollar(u"dollar \$escape\$ too")==u"dollar $escape$ too"
-    assert replace_dollar(u"spaces $in the$ math")==u"spaces :math:`in the` math"
-    assert replace_dollar(u"emb\ $ed$\ ed")==u"emb\ :math:`ed`\ ed"
-    assert replace_dollar(u"$first$a")==u"$first$a"
-    assert replace_dollar(u"a$last$")==u"a$last$"
-    assert replace_dollar(u"$37")==u"$37"
-    assert replace_dollar(u"($37)")==u"($37)"
-    assert replace_dollar(u"$37 - $43")==u"$37 - $43"
-    assert replace_dollar(u"($37, $38)")==u"($37, $38)"
-    assert replace_dollar(u"a $mid$dle a")==u"a $mid$dle a"
-    assert replace_dollar(u"a ($in parens$) a")==u"a (:math:`in parens`) a"
-    assert replace_dollar(u"a (again $in parens$) a")==u"a (again :math:`in parens`) a"
+    """
+    Test substitution of dollar signs with equivalent RST math markup
+    """
+    assert replace_dollar(u"no dollar") == u"no dollar"
+    assert replace_dollar(u"$only$") == u":math:`only`"
+    assert replace_dollar(u"$first$ is good") == u":math:`first` is good"
+    assert replace_dollar(u"so is $last$") == u"so is :math:`last`"
+    assert replace_dollar(u"and $mid$ too") == u"and :math:`mid` too"
+    assert replace_dollar(u"$first$, $mid$, $last$") == u":math:`first`, :math:`mid`, :math:`last`"
+    assert replace_dollar(ur"dollar\$ escape") == u"dollar$ escape"
+    assert replace_dollar(ur"dollar \$escape\$ too") == u"dollar $escape$ too"
+    assert replace_dollar(u"spaces $in the$ math") == u"spaces :math:`in the` math"
+    assert replace_dollar(u"emb\ $ed$\ ed") == ur"emb\ :math:`ed`\ ed"
+    assert replace_dollar(u"$first$a") == u"$first$a"
+    assert replace_dollar(u"a$last$") == u"a$last$"
+    assert replace_dollar(u"$37") == u"$37"
+    assert replace_dollar(u"($37)") == u"($37)"
+    assert replace_dollar(u"$37 - $43") == u"$37 - $43"
+    assert replace_dollar(u"($37, $38)") == u"($37, $38)"
+    assert replace_dollar(u"a $mid$dle a") == u"a $mid$dle a"
+    assert replace_dollar(u"a ($in parens$) a") == u"a (:math:`in parens`) a"
+    assert replace_dollar(u"a (again $in parens$) a") == u"a (again :math:`in parens`) a"
 
 if __name__ == "__main__":
Index: sasmodels/sasview_model.py
===================================================================
--- sasmodels/sasview_model.py	(revision 50ec5155a86f50e85db2a2702dd2e7952afbf09f)
+++ sasmodels/sasview_model.py	(revision b32dafd2b778081295c58e5d7727689b2b42fc68)
@@ -45,4 +45,9 @@
 MODELS = {}
 def find_model(modelname):
+    # type: (str) -> SasviewModelType
+    """
+    Find a model by name.  If the model name ends in py, try loading it from
+    custom models, otherwise look for it in the list of builtin models.
+    """
     # TODO: used by sum/product model to load an existing model
     # TODO: doesn't handle custom models properly
@@ -340,5 +345,5 @@
             else:
                 value = np.array([self.params.get(p.id+str(k), np.NaN)
-                                  for k in range(1,p.length+1)])
+                                  for k in range(1, p.length+1)])
             args[p.id] = value
 
@@ -587,5 +592,4 @@
             # new dispersers in the set_dispersion call and create a new
             # one instead of trying to assign parameters.
-            from . import weights
             disperser = weights.dispersers[dispersion.__class__.__name__]
             dispersion = weights.MODELS[disperser]()
@@ -634,5 +638,5 @@
     Cylinder = _make_standard_model('cylinder')
     cylinder = Cylinder()
-    return cylinder.evalDistribution([0.1,0.1])
+    return cylinder.evalDistribution([0.1, 0.1])
 
 def test_rpa():
@@ -643,5 +647,5 @@
     RPA = _make_standard_model('rpa')
     rpa = RPA(3)
-    return rpa.evalDistribution([0.1,0.1])
+    return rpa.evalDistribution([0.1, 0.1])
 
 
