0

I am trying to get a random image from the top 10 posts on the "memes" Reddit subreddit, but it's giving a E1101 pylint error. I seem to have done everything correctly. Here is my code:

I cant seem to find anything on this.

reddit = praw.Reddit(client_id='my client ID',
    client_secret='my client secret',
    user_agent='my user agent',
    username='username')




@commands.command()
async def meme(self):
    memes = reddit.subreddit('memes').hot()
    post_to_pick = random.randint(1, 10)
    for i in range(0, post_to_pick):
        submission = next(x for x in memes if not x.stickied)
  • Can you point out which line is the linter throwing that msg? – thuyein Jan 04 '19 at 04:37
  • If a class uses `setattr` to create attributes at runtime, Pylint can't detect those. See this question https://stackoverflow.com/q/35990313/494134 – John Gordon Jan 04 '19 at 04:47
  • @ThuYeinTun memes = reddit.subreddit('memes').hot() reddit specifically – That Thing Jan 04 '19 at 04:49
  • [Here's the line where `Reddit.subreddit` is defined](https://github.com/praw-dev/praw/blob/master/praw/reddit.py#L222). I would expect your linter to see that. Are your `praw` and `pylint` installations both their most recent versions? – Patrick Haugh Jan 04 '19 at 05:14
  • both praw and pylint are updated – That Thing Jan 04 '19 at 05:27

1 Answers1

1

That's because pylint by default only trusts C extensions from the standard library and will ignore those that aren't.

As praw isn't part of stdlib, you have to whitelist it manually. To do this, navigate to the directory of your project in a terminal, and generate an rcfile for pylint:

$ pylint --generate-rcfile > .pylintrc

Then, open that file and add praw to the whitelist like so:

extension-pkg-whitelist=praw

After that, all E1101 errors regarding praw shouldn't appear anymore

More details in this answer.

Tristo
  • 2,328
  • 4
  • 17
  • 28