it is valid, its a ternary inside of a list comp. I agree its convoluted and suspect the autopep8 played with it. Here it is adjusted:

```python
[md[id_] if id_ in md else None 
 for id_ in self.sample_ids]
```