Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
WIP: Read from stdin #1189
This is obviously not ready for merging; I just wanted to explore a potential implementation for GH-1187.
This PR makes it possible to pass "-" as a filename to pylint, along with a
I'd like some help to understand:
Parts of this should probably go into astroid, too.
referenced this pull request
Feb 5, 2017
This would be really nice to integrate into IDEs better (i.e.: to do a code-analysis with PyLint having dirty contents inside the IDE).
One thing I noticed is that the pull request has no tests (so, probably a blocker for commit).
Unfortunately, I can't really comment on the general approach -- I'm not really that familiar with the PyLint codebase ;)
Thanks for taking a look! Should be fairly easy to reuse most of the integration tests (by feeding files on stdin). But I didn't want to start doing that until I got at least some word from the Pylint devs. The trick is, they said it would be hard to do when I asked for the feature, so I thought I'd provide a draft to start a discussion :)
Well, I'm not a PyLint dev, but maybe I can help spur some discussion...
I think the best approach would be making it more targeted (there should be a single place which loads a file content and converts it to an AST -- i.e.: MANAGER.ast_from_file(filepath, modname, source=True))
I think that I'd just create some config in the related library which lets you create a dict(filepath->override contents) and set that when stdin with a filepath is chosen (without touching any other related code).
This probably happens on astroid, so, I'd start getting that feature (preset file contents) there and then coming to PyLint to use it.
Also, you probably need to take some care to always access the keys on that dict by real/abs paths (so that if it's accessed by 2 places from symlinks the same overridden contents are used).
I think that's pretty close to what the code already does (it calls that a proxy, which allows you to decouple what file you claim to be checking and where you read from. The where is only stdin in my patch, but that would be easy to extend.
The current strategy requires adding just two functions to Astroid, which sounds like a feature. In particular, the notion of proxying doesn't need to exist there.
But all in all, I don't think I'm going to write more code for this until I get at least a sign of life from the Pylint devs :) This is almost 4 months old, so I don't want to invest more time without knowing if it'll ever pay off.
Sorry for coming so late commenting on this issue.