Add pyyaml dependency and simplify datetime type checking

- Add pyyaml>=6.0.3 to dependencies
- Simplify _is_datetime_type to use get_args directly instead of Union check
- Update test assertion message for permission denied error
