Two things can improve pants project: 1-No import ...
# general
f
Two things can improve pants project: 1-No import for individual function or classes directly from the modules. Instead, import the modules then access the function or class from the module. It will make namespacing better. I saw lot of code that say
from foo.bar import OrderedDict
, then another part of the project say
from twitter.foo.x import OrderedDict
. I feel it make it really hard to distinguish. 2-The second thing. Test are located outside of the source code directory. If I want to know a module has a unittest, I will need to open a separate directory outside of the project source code, and look for the unittests. Unittests are used as a document to understand how the module works. At Google, all of the unittests are located next to the module. If you open any directory. You will see something like this:
foo.py
and
foo_test.py
. Here at the company I work at we create a directory called
tests
and we store all the tests related to the modules in it. So, if I have
foo.py
in a directory, the test will be located in
tests/foo_test.py
in the same directory of
foo.py
.