It's just personal preference, but can't this be written as:
```python
if callback:
    if callback_pattern.match(callback):
        # ...
    else:
        # ...
```
?