pyunlocbox
pyunlocbox copied to clipboard
[WIP] docstrings: automatically import pyunlocbox & numpy
It makes for cleaner doctests, but it doesn't pass make lint
with errors like F821 undefined name 'operators'
.
We should probably switch to black before spending time to make flake8
happy.
I think swichting to black is a good idea.
Do you want me to give a shot at this?
I would go with the following steps:
- Go back one commit
- Rebase on master
- Fix make lint by swtiching to
black
- Check if numpy and pyunlocbox in imported in some other place
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
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
?
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).