pylint icon indicating copy to clipboard operation
pylint copied to clipboard

pylint doesn't support pygments lexers/formatters

Open pylint-bot opened this issue 10 years ago • 6 comments

Originally reported by: Florian Bruhin (BitBucket: The-Compiler, GitHub: @The-Compiler?)


For this code:

import pygments.lexers
import pygments.formatters

foo = pygments.lexers.HtmlLexer
bar = pygments.formatters.HtmlFormatter

pylint shows Module 'pygments.lexers' has no 'HtmlLexer' member (no-member) and Module 'pygments.formatters' has no 'HtmlFormatter' member (no-member).

It seems pygments does some magic with sys.modules for its lexers/formatters, so maybe this is too complicated for pylint to handle. Just opening this if there's some existing easy mechanism in pylint for this.


  • Bitbucket: https://bitbucket.org/logilab/pylint/issue/491

pylint-bot avatar Mar 11 '15 16:03 pylint-bot

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Yes, there is a mechanism, astroid.brain tips. We already have something for these type of modules: pytest, nose etc. Adding one for pygments.lexers shouldn't be that hard.

pylint-bot avatar Mar 11 '15 16:03 pylint-bot

In 5 days the issue will hit its 10 year anniversary :tada:

And it still exists. Importing from pygments.formatters triggers Pylint errors, even though the imports themselves (NullFormatter and TerminalFormatter) are completely valid and usable.

Though, I'm not sure if this is Pygments's problem at all. pygments.formatters has a variable __all__ and there is a list(FORMATTERS) appended to it. For some reason Pylint doesn't acknowledge this.

Image

synalice avatar Mar 06 '25 15:03 synalice

We could make an astroid brain like PCManticore said 9 year and 363 days ago, or we can take the content of __all__ into account in astroid and think about https://github.com/pylint-dev/astroid/issues/322 / https://github.com/pylint-dev/astroid/commit/5f9f8df7aa92981fbb41ea01535c5928ec8c2e08 again.

Pierre-Sassoulas avatar Mar 09 '25 11:03 Pierre-Sassoulas

"Will we go with solution A or solution B? Tune in on March 11, 2035 to find out!"

Seriously though, yes, it would be nice for a solution to be implemented. 🙂

TomerGodinger avatar Apr 07 '25 14:04 TomerGodinger

When no maintainer or contributors has been affected by this enough to be bothered to implement a fix in 10 years, the best chance of a fix to happen is for you, (you being annoyed by this enough to be reading this issue, not @TomerGodinger in particular), to design it, implements it and become the people's hero.

Pierre-Sassoulas avatar Apr 07 '25 14:04 Pierre-Sassoulas

Yeah, when faced with the options of studying the design and implementation of a program or adding a comment to your code, it's pretty obvious what people would normally do, so it's not a surprise that it's been left alone.

I'd like to say I'd take a look, but realistically speaking I can't say if/when I'll ever get to it. (P.S. I hope my joke wasn't taken badly; I didn't mean it as criticism, but rather as an observation of the situation.)

TomerGodinger avatar Apr 08 '25 07:04 TomerGodinger