Fix static analysis errors in IPython.core.formatters

Closes gh-7054