The whole ```if``` clause can be simplified to:

```
if remote_groups in ('only_local', 'remote'):
```

We don't need to check for `remote_groups` being None, and besides if `remote_groups` is not set and `default_groups` is, your code will fail on line 289