Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylint does not find open_nursery and run methods #592

Closed
jmfrank63 opened this issue Aug 4, 2018 · 1 comment
Closed

pylint does not find open_nursery and run methods #592

jmfrank63 opened this issue Aug 4, 2018 · 1 comment

Comments

@jmfrank63
Copy link
Contributor

jmfrank63 commented Aug 4, 2018

This might not be a trio problem, I am aware of this:

# -*- coding: utf-8 -*-

import trio

async def toddler():
    print('Toddler is playing...')
    await trio.sleep(5)

async def parent():
    async with trio.open_nursery() as nursery: #pylint: disable=no-member
        print('Bringing toddler to nursery...')
        nursery.start_soon(toddler)
    print('Going home...')

if __name__ == '__main__':
    trio.run(parent)

In this code above pylint on python 3.7 complains about not finding members:

##########Linting Output - pylint##########
************* Module issue
10,15,error,E1101:Module 'trio' has no 'open_nursery' member
17,4,error,E1101:Module 'trio' has no 'run' member

------------------------------------------------------------------
Your code has been rated at 1.67/10 (previous run: 1.67/10, +0.00)

The issue can obviously worked around by ignoring.

ipython finds both functions with code completion.

Also reported against pylint.

@njsmith
Copy link
Member

njsmith commented Aug 5, 2018

Yes, this has come up a few times, and it's kind of both trio and pylint's fault: pylint is using imperfect heuristics to try to guess what members are exported from a module, and trio's exports are put together in a complicated way that pylint's heuristics don't work on. There are similar issues with other tools that try to analyze trio statically (like mypy, pycharm, etc.), rather than at runtime (like ipython).

Unfortunately we can't really fix all those tools, so we should change how trio does exports. We have an open issue for that: #542. No-one's started working on it yet, but I'm sure it will happen sometime... or if it's something you wanted to work on then speak up there or in chat and we can help you figure out how to get started.

(Closing this in favor of #542.)

@njsmith njsmith closed this as completed Aug 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants