Fix static analysis errors in IPython.core.formatters

Closes gh-7054
Merge pull request #7060 from takluyver/i7054

Fix static analysis errors in IPython.core.formatters