Pygments relies on global imports of its own modules, breaking local installs

Issue #1448 new
Tab Atkins-Bittner
created an issue

The Pygments source files import each other like from import bar. If you have a globally-installed Pygments, this'll import correctly. But if you also have a local version of Pygments in some project, the local version will end up importing from the global version, and then various things will fail.

(In particular, the type-check that occurs at will fail, because has imported the global version of _TokenType, but my code is importing the local version of, whose instances are all derived from the local _TokenType, so they fail the type-check.)

This can be easily fixed by using proper relative imports, like from .foo import bar - this is how I fixed it in my local copy. I'm happy to submit a PR to switch everything to relative imports, if that would be accepted.

(You can see the failure, attendant stack-trace, and fix in

Comments (0)

  1. Log in to comment