pyunlocbox icon indicating copy to clipboard operation
pyunlocbox copied to clipboard

[WIP] docstrings: automatically import pyunlocbox & numpy

Open mdeff opened this issue 4 years ago • 6 comments

It makes for cleaner doctests, but it doesn't pass make lint with errors like F821 undefined name 'operators'.

mdeff avatar Mar 24 '20 16:03 mdeff

We should probably switch to black before spending time to make flake8 happy.

mdeff avatar Mar 24 '20 17:03 mdeff

I think swichting to black is a good idea.

nperraud avatar Mar 25 '20 08:03 nperraud

Do you want me to give a shot at this?

I would go with the following steps:

  1. Go back one commit
  2. Rebase on master
  3. Fix make lint by swtiching to black
  4. Check if numpy and pyunlocbox in imported in some other place

nperraud avatar Jan 27 '21 08:01 nperraud

Note that here I do not import numpy but it does not complain:

https://github.com/epfl-lts2/pyunlocbox/blob/be4b6a2805f79536164dd7218b412f685181c98c/pyunlocbox/functions.py#L880

nperraud avatar Jan 27 '21 08:01 nperraud

Note that here I do not import numpy but it does not complain:

Oh that is weird. Not only doesn't make lint complain, but the doctest passes. I also tried to remove from pyunlocbox import functions: the doctest passes too but make lint complains about F821 undefined name 'functions'. So it seems that both doctest and flake8 recognize np as being numpy (without configuration), while only doctest recognizes functions to be pyunlocbox.functions.

That issue won't be fixed by black. We have to somehow tell flake8 that functions, solvers, etc. are found in pyunlocbox. Maybe by understanding how it's ok for np not to be imported. Or you meant replacing flake8 by black?

mdeff avatar Jan 27 '21 13:01 mdeff

I think of them as complementary: black formats the code, and flake8 checks (in CI) that it's ok. Black doesn't make checks right?

But I'm all to have black. It'll save us review time. :) But in another PR (which could be done before this one if necessary).

mdeff avatar Jan 27 '21 13:01 mdeff