ancient-france-42909
05/04/2023, 5:30 PMinterpreter_constraints=[
"CPython~=3.7.4",
"CPython~=3.10.9",
]
to python_sources
and
interpreter_constraints=parametrize(
py37=["~=3.7.4"],
py310=["~=3.10.9"],
),
to our python_tests
. The idea being, we mark libs as compatible, then run tests on both. So this works sort of okay, until this interacts with init file inference (here). When this has the default value, we get:
pants.engine.target.InvalidFieldException: The target filters/src/messages/tests/unit/templates/test_helpers.py:../../../test@interpreter_constraints=py37 has the `interpreter_constraints` ('~=3.7.4',), which are not a subset of the `interpreter_constraints` of some of its dependencies:
* ('~=3.10.9',): filters/src/messages/tests/unit/templates/__init__.py:../../../test@interpreter_constraints=py310
To fix this, you should likely adjust filters/src/messages/tests/unit/templates/test_helpers.py:../../../test@interpreter_constraints=py37's `interpreter_constraints` to match the narrowest range in the above list.
Aside turning that off, what can we do?ancient-france-42909
05/04/2023, 5:46 PMwitty-crayon-22786
05/04/2023, 6:38 PMancient-france-42909
05/04/2023, 6:39 PMwitty-crayon-22786
05/04/2023, 6:39 PMconftest.py
witty-crayon-22786
05/04/2023, 6:40 PMwitty-crayon-22786
05/04/2023, 6:40 PMancient-france-42909
05/04/2023, 6:40 PMpython_tests(
name="test",
sources=["tests/**/*.py", "!tests/**/conftest.py"],
dependencies=[
":lib",
":test-utils",
":test-files",
"common/testing/src:lib",
"filters/src/core:lib",
"filters/src/emails:lib",
"defender:lib",
"requirements/python#testfixtures",
"requirements/python#html2text",
"requirements/python#freezegun",
"requirements/python#beautifulsoup4",
],
tags=["mono"],
interpreter_constraints=parametrize(
py37=["~=3.7.4"],
py310=["~=3.10.9"],
),
)
This is the tests target, and it includes both the __init__.py
and the test, in sourcesancient-france-42909
05/04/2023, 6:42 PM:lib
is the actual library, the one that we didn't parametrise, test-files
are just some resources (yamls and such), test-utils
are test_utils
with `conftest.py`s and the rest are just other libs in our codewitty-crayon-22786
05/04/2023, 6:42 PMwitty-crayon-22786
05/04/2023, 6:42 PMwitty-crayon-22786
05/04/2023, 6:43 PM./pants list filters/src/messages/tests/unit/templates/__init__.py
report?ancient-france-42909
05/04/2023, 6:43 PMfilters/src/messages/tests/unit/templates/__init__.py:../../../test@interpreter_constraints=py37
filters/src/messages/tests/unit/templates/__init__.py:../../../test@interpreter_constraints=py310
ancient-france-42909
05/04/2023, 6:45 PMfilters/src/messages/tests/unit/templates/test_helpers.py:../../../test@interpreter_constraints=py310
filters/src/messages/tests/unit/templates/test_helpers.py:../../../test@interpreter_constraints=py37
witty-crayon-22786
05/04/2023, 6:45 PMwitty-crayon-22786
05/04/2023, 6:46 PMwitty-crayon-22786
05/04/2023, 6:46 PM__init__.py
to be wider?ancient-france-42909
05/04/2023, 6:46 PMancient-france-42909
05/04/2023, 6:47 PMancient-france-42909
05/04/2023, 6:48 PM__init__.py
(why is it so hard to write that in slack :P)witty-crayon-22786
05/04/2023, 6:48 PMpython_tests(
name="test",
...,
interpreter_constraints=parametrize(
py37=["~=3.7.4"],
py310=["~=3.10.9"],
),
overrides={
'__init__.py': dict(
interpreter_constraints=[">=3.7.4,<=3.10.9"],
)
}
)
ancient-france-42909
05/04/2023, 6:49 PMwitty-crayon-22786
05/04/2023, 6:49 PMparametrize
and overrides
is … interesting to reason about.ancient-france-42909
05/04/2023, 6:49 PM<3.11
witty-crayon-22786
05/04/2023, 6:50 PMancient-france-42909
05/04/2023, 6:51 PMancient-france-42909
05/04/2023, 6:52 PMancient-france-42909
05/04/2023, 6:52 PMpants.engine.target.InvalidFieldException: The target filters/src/messages/tests/unit/templates/__init__.py:../../../test@interpreter_constraints=py37 has the `interpreter_constraints` ('>=3.7.4,<3.11',), which are not a subset of the `interpreter_constraints` of some of its dependencies:
* ('CPython~=3.7.4', 'CPython~=3.10.9'): filters/src/messages/tests/conftest.py:../test_utils
* ('CPython~=3.7.4', 'CPython~=3.10.9'): filters/src/messages/tests/unit/conftest.py:../../test_utils
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_defender_compliance_alert.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_helpers.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_html_templates.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_plaintext_templates.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_rtf_templates.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_attachment_hash_denylisted.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_attachment_urls.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_content_generation.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_demo_flags_output.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_element_list.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_malicious_attachment_urls.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_message_elements.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_simple_message_element.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_threat_intelligence.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_warning_item_ordering.py:../../test@interpreter_constraints=py37
ancient-france-42909
05/04/2023, 6:52 PMwitty-crayon-22786
05/04/2023, 6:53 PM__init__.py
also has dependencies? fun.ancient-france-42909
05/04/2023, 6:53 PMwitty-crayon-22786
05/04/2023, 6:55 PMpython_tests(
name="test",
...,
interpreter_constraints=parametrize(
py37=["~=3.7.4"],
py310=["~=3.10.9"],
),
overrides={
'__init__.py': dict(
interpreter_constraints=["~=3.7.4","~=3.10.9"],
)
}
)
ancient-france-42909
05/04/2023, 6:55 PMwitty-crayon-22786
05/04/2023, 6:55 PMancient-france-42909
05/04/2023, 6:55 PMpants.engine.target.InvalidFieldException: The target filters/src/messages/tests/unit/templates/__init__.py:../../../test@interpreter_constraints=py37 has the `interpreter_constraints` ('~=3.7.4', '~=3.10.9'), which are not a subset of the `interpreter_constraints` of some of its dependencies:
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_defender_compliance_alert.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_helpers.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_html_templates.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_plaintext_templates.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/templates/test_rtf_templates.py:../../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_attachment_hash_denylisted.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_attachment_urls.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_content_generation.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_demo_flags_output.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_element_list.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_malicious_attachment_urls.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_message_elements.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_simple_message_element.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_threat_intelligence.py:../../test@interpreter_constraints=py37
* ('~=3.7.4',): filters/src/messages/tests/unit/test_warning_item_ordering.py:../../test@interpreter_constraints=py37
ancient-france-42909
05/04/2023, 6:57 PM~=3.7.4
😞ancient-france-42909
05/04/2023, 6:58 PMancient-france-42909
05/04/2023, 6:58 PMwitty-crayon-22786
05/04/2023, 6:59 PMresolve
field, but not for interpreter_constraints.witty-crayon-22786
05/04/2023, 6:59 PMwitty-crayon-22786
05/04/2023, 6:59 PMancient-france-42909
05/04/2023, 6:59 PM__init__.py
, then I'll try to get a minimal reproducible exampleancient-france-42909
05/04/2023, 7:00 PMwitty-crayon-22786
05/04/2023, 7:00 PMinterpreter_constraints
supports sets without parametrizationwitty-crayon-22786
05/04/2023, 7:01 PMinterpreter_constraints=[">=3.7.4,<=3.10.9"]
• converted tests: … can either parametrize, or use one or the other versionancient-france-42909
05/04/2023, 7:02 PMwitty-crayon-22786
05/04/2023, 7:02 PM__init__.py
files out of your test targets, regardless =/witty-crayon-22786
05/04/2023, 7:03 PM__init__.py
files are not included in python_tests
by default anyway… i think that your globs have re-included them.witty-crayon-22786
05/04/2023, 7:03 PMtailor
, it should fix it for you.ancient-france-42909
05/04/2023, 7:04 PMancient-france-42909
05/04/2023, 7:04 PMwitty-crayon-22786
05/04/2023, 7:04 PMtailor
choose it’s default =Pancient-france-42909
05/04/2023, 7:05 PMancient-france-42909
05/04/2023, 7:06 PM__defaults__
, to do this for every python_tests
ancient-france-42909
05/04/2023, 7:07 PMwitty-crayon-22786
05/04/2023, 7:07 PMtailor
does by default?ancient-france-42909
05/04/2023, 7:08 PMBUILD
files when they add a new lib/appwitty-crayon-22786
05/04/2023, 7:08 PMI guess there’s no way, usinghm… there might be? why don’t you think that, to do this for every__defaults__
python_tests
__defaults__
will work for this?ancient-france-42909
05/04/2023, 7:09 PMwitty-crayon-22786
05/04/2023, 7:10 PM__defaults__
, you’d have to remove the explicit argumentsancient-france-42909
05/04/2023, 7:10 PMancient-france-42909
05/04/2023, 7:10 PMancient-france-42909
05/04/2023, 7:15 PMancient-france-42909
05/04/2023, 7:15 PMwitty-crayon-22786
05/04/2023, 7:15 PM__defaults__
and then nuking that field might be worth it. but yea, up to you.ancient-france-42909
05/04/2023, 7:16 PMBUILD
witty-crayon-22786
05/04/2023, 7:16 PMwitty-crayon-22786
05/04/2023, 7:17 PMancient-france-42909
05/04/2023, 7:18 PMtailor
so I have no idea what that generateswitty-crayon-22786
05/04/2023, 7:19 PMwitty-crayon-22786
05/04/2023, 7:19 PMancient-france-42909
05/04/2023, 7:21 PMtailor
on that folder, it was useless, hehancient-france-42909
05/04/2023, 7:21 PMpython_sources()
at the end of the BUILD
fileswitty-crayon-22786
05/04/2023, 7:22 PMancient-france-42909
05/04/2023, 7:22 PMBUILD
filesancient-france-42909
05/04/2023, 7:22 PMpython_test_utils(
name="test_utils",
)
python_tests(
name="tests",
)
ancient-france-42909
05/04/2023, 7:22 PMancient-france-42909
05/04/2023, 7:23 PMwitty-crayon-22786
05/04/2023, 7:23 PMtailor
is that you never need to manually declare targets: they exist only as places to add metadata like extra dependencies, interpreter constraints, etcwitty-crayon-22786
05/04/2023, 7:23 PM--check
modeancient-france-42909
05/04/2023, 7:24 PMsources
for any of the things it added.witty-crayon-22786
05/04/2023, 7:24 PMI’m not sure how this is helpful, first people need to make sure they run this command before they commit, but ALSO, they have to figure out what’s missing?to be clear: people already need to figure out what files don’t have owning targets: how are you doing that now?
witty-crayon-22786
05/04/2023, 7:24 PMThere are noit’s using the default source globs for the targetfor any of the things it added.sources
witty-crayon-22786
05/04/2023, 7:24 PM./pants list directory:
before and after: most likely there was an unowned file in there.ancient-france-42909
05/04/2023, 7:24 PMsources=["filters/**/*.py"]
ancient-france-42909
05/04/2023, 7:25 PM__init__.py
files?witty-crayon-22786
05/04/2023, 7:25 PMancient-france-42909
05/04/2023, 7:25 PMancient-france-42909
05/04/2023, 7:27 PMBUILD
files per directory that we have from above.ancient-france-42909
05/04/2023, 7:28 PMwitty-crayon-22786
05/04/2023, 7:28 PMwitty-crayon-22786
05/04/2023, 7:28 PMancient-france-42909
05/04/2023, 7:29 PMwitty-crayon-22786
05/04/2023, 7:29 PMancient-france-42909
05/04/2023, 7:31 PMResolve transitive targets
, not sure which one that is.witty-crayon-22786
05/04/2023, 7:31 PMancient-france-42909
05/04/2023, 7:32 PMwitty-crayon-22786
05/04/2023, 7:32 PMancient-france-42909
05/04/2023, 7:33 PMancient-france-42909
05/04/2023, 7:35 PMancient-france-42909
05/04/2023, 7:40 PM__init__.py
did fix the problem.