loud-laptop-17949
04/19/2022, 6:12 PMsrc/django_apps/files/models.py:21:0: E0401: Unable to import 'util.url' (import-error)
Though pants shows them as a dependency:
$ p dependencies src/django_apps/files/models.py
...
src/util/url.py
What am I missing here?hundreds-father-404
04/19/2022, 6:16 PMeager-dress-66405
04/19/2022, 6:16 PM./pants lint src/django_apps/files/models.py
works
./pants lint src/django_apps/files::
works
Only happens on very large pants lint runs and which files see these unable to import errors for seems to shift arondloud-laptop-17949
04/19/2022, 6:18 PM./pants filter --sep="\0" :: | xargs -0 ./pants lint
seems to always trigger it thoeager-dress-66405
04/19/2022, 6:18 PMloud-laptop-17949
04/19/2022, 6:18 PMsparse-lifeguard-95737
04/19/2022, 6:23 PM./pants filter :: | wc -l
prints 7450 for me. xargs
has a default value 5000 for -n
(at least according to man
), is it possible we’re splitting transitive deps across separate calls to ./pants lint
?eager-dress-66405
04/19/2022, 6:24 PM./pants lint <one file>
workseager-dress-66405
04/19/2022, 6:46 PM./__run.sh
repeats the error. What now?hundreds-father-404
04/19/2022, 6:50 PMeager-dress-66405
04/19/2022, 6:52 PMeager-dress-66405
04/19/2022, 6:52 PM/tmp/process-execution9TnW2S$ ./__run.sh |grep import-error|cut -d: -f5|sort | uniq -c
2 Unable to import 'util.async_task' (import-error)
4 Unable to import 'util.celery' (import-error)
4 Unable to import 'util.common' (import-error)
17 Unable to import 'util.constants' (import-error)
1 Unable to import 'util.date' (import-error)
2 Unable to import 'util.iterables' (import-error)
2 Unable to import 'util.iter' (import-error)
2 Unable to import 'util.jira' (import-error)
5 Unable to import 'util.phone_number' (import-error)
1 Unable to import 'util.requests' (import-error)
5 Unable to import 'util.s3' (import-error)
2 Unable to import 'util.string' (import-error)
19 Unable to import 'util.testutil' (import-error)
2 Unable to import 'util.text_mailer' (import-error)
3 Unable to import 'util.url' (import-error)
hundreds-father-404
04/19/2022, 6:53 PMsrc
thougheager-dress-66405
04/19/2022, 6:53 PM/tmp/process-execution9TnW2S/src/util/{module}.py
exists for all of the abovewitty-crayon-22786
04/19/2022, 6:53 PMI wonder if maybe source roots are not being set up correctly...?and/or
__init__.py
fileseager-dress-66405
04/19/2022, 6:54 PM/src
eager-dress-66405
04/19/2022, 6:55 PM__init__.py
file does not helpeager-dress-66405
04/19/2022, 6:56 PMeager-dress-66405
04/19/2022, 6:56 PM/
and /src
as root patterns in our pants.toml
hundreds-father-404
04/19/2022, 6:57 PMeager-dress-66405
04/19/2022, 6:58 PM************* Module src.django_apps.files.models
src/django_apps/files/models.py:21:0: E0401: Unable to import 'util.url' (import-error)
eager-dress-66405
04/19/2022, 6:59 PMsrc.django_apps.files.models
, not django_apps.files.models
eager-dress-66405
04/19/2022, 6:59 PMexport PEX_EXTRA_SYS_PATH=$'build/python-packages/color-django-extensions:src:__plugins'
eager-dress-66405
04/19/2022, 6:59 PMPEX_EXTRA_SYS_PATH
it looks righteager-dress-66405
04/19/2022, 7:00 PMsrc
in the PATH i would think import util.url
would workeager-dress-66405
04/19/2022, 7:01 PM/tmp/process-execution9TnW2S$ ls -lah src/util/url.py
-rw-r--r-- 1 mpcusack mpcusack 1.2K Apr 19 14:42 src/util/url.py
hundreds-father-404
04/19/2022, 7:05 PMeager-dress-66405
04/19/2022, 7:06 PM/tmp/process-execution9TnW2S$ PEX_EXTRA_SYS_PATH=$'build/python-packages/color-django-extensions:src:__plugins' ./pylint_runner.pex_pex_shim.sh $'--rcfile=.pylintrc' $'--jobs=8' src/django_apps/files/models.py
Has no errorseager-dress-66405
04/19/2022, 7:07 PM__run.sh
script that passes ~280 additional files it failshundreds-father-404
04/19/2022, 7:08 PMhundreds-father-404
04/19/2022, 7:08 PMeager-dress-66405
04/19/2022, 7:08 PMeager-dress-66405
04/19/2022, 7:09 PMsrc/django_apps/::
and looking at the args that is trueeager-dress-66405
04/19/2022, 7:09 PMbuild/python-packages/color-django-extensions
on the path, one of them is likely importing from that alternative python rooteager-dress-66405
04/19/2022, 7:10 PMeager-dress-66405
04/19/2022, 9:10 PM./pants lint src/django_apps/files/models.py src/django_apps/feed/services/consult/util.py
Adding a __init__.py
to src/django_apps/feed/services/consult
fixes it.eager-dress-66405
04/19/2022, 9:17 PMsrc/django_apps/feed/services/consult/__init__.py
would cause lint errors in src/django_apps/files/models.py
? It seems like without it is using /
at the python root instead of /src
.
• We have no other dirs named directories named consult
$ find . -type d -name consult
./src/django_apps/feed/services/consult
At least for pytest the init files are only required when there is a package name overlap.
• When should we need init scripts?