Trailing whitespace not working

I just installed pre-commit, added this .pre-commit-config.yaml file:

# See http://pre-commit.com for more information
# See http://pre-commit.com/hooks.html for more hooks
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    sha: v1.1.1
    hooks:
    -   id: trailing-whitespace

and added a trailing space to a line in a file in the project, staged it, and when I commit it, it commits with the space, instead of removing it.