use context manager for warn_only=True