The correct operator would probably, or at least should be, named something to do with ‘excluding’.
Operators only work in very specific contexts. You’ll likely need to give it a context override to work, check the api documentation on operators for information on this.
The better way to set the exclusion is to manipulate the variables in the view_layer context like the following.