Is it intentional that " [WARN] Unmatched globs" i...
# general
c
Is it intentional that " [WARN] Unmatched globs" is given for /excludes/ that don't match(. That is
Copy code
python_tests(
    name="tests",
    sources = ['test_*.py', '*_test.py', 'tests.py',  "!test_integration_*.py"]

)
would give
Copy code
13:25:45.89 [WARN] Unmatched globs from helloworld/greet:tests's `sources` field: ["helloworld/greet/test_*.py", "helloworld/greet/tests.py"], exclude: "helloworld/greet/test_integration_*.py"
if there was not a
test_integration_foo.py
file.
c
I think it makes as much sense as the opposite, that it warns for a glob to include that doesn’t match. In either case you have a redundant glob pattern in your sources list.
however, the question has been raised in the past about having support for truly optional globs, that doesn’t care.
c
hmm, I'm more confused though. If that's the behavior, why doesn't every directory without a
conftest.py
give a warning from the default python_sources:
Copy code
$ pants peek helloworld/greet:lib
[
  {
    "address": "helloworld/greet:lib",
    "target_type": "python_sources",
    "dependencies": [
      "helloworld/greet/__init__.py:lib",
      "helloworld/greet/greeting.py:lib"
    ],
    "description": null,
    "overrides": null,
    "skip_black": false,
    "skip_docformatter": false,
    "skip_flake8": false,
    "skip_isort": false,
    "skip_mypy": false,
    "sources": [
      "helloworld/greet/__init__.py",
      "helloworld/greet/greeting.py"
    ],
    "sources_fingerprint": "e4b3e53d6b26824dab6f469c85a83a27dd89c31516ad493e56b5e735e6ab7430",
    "sources_raw": [
      "*.py",
      "*.pyi",
      "!test_*.py",
      "!*_test.py",
      "!tests.py",
      "!conftest.py",
      "!test_*.pyi",
      "!*_test.pyi",
      "!tests.pyi"
    ],
    "tags": null
  }
c
that’s an unfortunate difference with how a fields default glob is treated compared to one you provide in the BUILD file. Try to set it to the exact same value to see what I mean.. 😉
I guess the rationale is that the field author is not expected to know what globs will be valid, so the defaults are all optional globs, where as those you set are not
c
🤯
c
indeed
c
So to have a
my_python_sources
that excludes `!conftest2.py, I'd need to write a plugin with those defaults?
c
unless you want to ignore missing globs repo-wide for all globs, yes.
assuming the above question was to use that exclude glob as a default (using
__defaults__
or similar).. if the file exists where that exclude glob is used, you don’t need to set it in a plugin, of course.
c
I was using a macro, but I think that's similar to defaults
c
yea, that’s the “or similar” 😉
basically, any way the target field gets its value that’s not from the default value on the fields class declaration.