The second line could also be updated to
```.py
rn = getattr(role, 'name', role)
```
but probably only because I don't really like the `a if X else b` syntax. Also the behavior is slightly different.