Skip to main content

Return error in ProviderCollection[] on undeclared provider

Currently,[UnknownInfo] returns None if foo is a provider collection.

This RFC proposes these changes:

  •[UnknownInfo] is an error
  • UnknownInfo in is False
  • returns None


Better diagnostics when accessing unknown provider. E. g. when writing:[UnknownInfo].bar

Currently, the error is:

Object of type `NoneType` has no attribute `bar`

Instead, the error will be something like:

provider collection does not contain `UnknownInfo`,
defined providers are `FooInfo`, `BarInfo`.


In bazel, [] on unknown provider is an error, like this:

Error: <target //optional_provider:n2> (rule '_sum')
doesn't contain declared provider 'UnknownInfo'