https://pantsbuild.org/ logo
#general
Title
# general
f

fresh-continent-76371

10/25/2022, 8:05 AM
Hello - i have a scenario, test migrating a repository over to pants, i have found a test which has a transitive dependency that, on import fails in the regex pattern ; in the current non-pants test matrix 3.8, 3.9, 3.10, the particular test succeeds; Presumably because the offending transitive import is not being loaded. The error in question (not germane to the problem) is a bad old regex with now invalid escape sequences.
Copy code
'e': ('[0-9]+\.?[0-9]+(?:e[-+]?[0-9]+)?', float),
E             ^
E   SyntaxError: invalid escape sequence \.
The current way of testing works is :
Copy code
coverage run --module --branch pytest --verbose --junit-xml=pytest_results.xml path/to/tests/test_subject.py
but when I run
Copy code
./pants test path/to/tests/test_subject.py
it fails with the deep transitive error (importing the lib fails - doesn't get to run the test) I have a sense that somehow, "coverage/pytest" is doing a lazy load, and not branching to this area of the test import. (or it is not actually testing like we think it is) and Pants is "not" lazy loading, thus when it hits this super old 3.9+ incompatible "escape sequence" it errors. Does anyone have any insights to this; it is good that Pants has uncovered this old escape sequence in the library that is old, but why do we not see it in the "current" testing method ;
l

lively-dusk-46231

10/25/2022, 9:00 AM
(Not an expert at pants) When you run:
Copy code
./pants dependencies path/to/tests/test_subject.py
Is the file with the offending line present ?
f

fresh-continent-76371

10/26/2022, 1:36 AM
no because it is a 3rd part, transitive dependency. eg
Copy code
./pants dependencies --transitive path/to/tests/test_subject.py                                                                                                                            
11:04:10.77 [INFO] Initializing scheduler...
11:04:11.04 [INFO] Scheduler initialized.
...
//:reqs0#offending-3rd-party-lib <-- This has another transitive dep, that has the problem 
...
Because Pants is not showing the full transitive dependencies, it stops at the top level 3rd party lib.
4 Views