-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lint all files in a directory #352
Comments
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore): Sounds good. I also encountered the need for this feature when running pylint over a large corpora of scripts. Nevertheless, Pylint shouldn't emit every time when it finds a folder without an init file, as in the case of the namespace packages from Python 3.3+. |
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore): Issue #512 was marked as a duplicate of this issue. |
Original comment by BitBucket: rneu31, GitHub: @rneu31?: Would the entire directory be scanned in a serial manner (in one thread/process)? For the CI process where I work we wrote a wrapper script that uses multiprocessing and consolidates the outputs of pylint (and various other tools) to avoid the large time hit of running Pylint across a large set of files. |
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore): The scanning should be serial, that is finding the files. The actual processing can already be parallelized with |
Original comment by Florian Bruhin (BitBucket: The-Compiler, GitHub: @The-Compiler?): @PCManticore mentioned someone worked on this on the EuroPython sprints but never uploaded a PR - if you're that person, can you maybe upload a PR (even if work-in-progress), so I could look at this when I have some time? |
I am looking into this enhancement. Will provide the update once code is ready. |
pylint can be run on directories as well now. All .py files are identified in the directory and pylint is executed on the those .py files.
Hi, Thanks, |
Is there any update on this / will this be a part of the 2.0 release? |
No one continued work on it. Unless someone takes charge of it, it will probably not be part of the 2.0 release. I will probably not have time to tackle it, since I have other priorities to bring to an end for 2.0. Note that in 2.0 we support implicit namespace packages. which have no init.py inside and supporting generic directories with scripts should not be that hard after all. |
I am unfortunately stuck using 2.7. I have been following some of the discussions on work being done for 2.0, but not the code directly. Is there any work in this area that makes sense to do? |
Yes, implementing this should be pretty straightforward once you figure out the details. I will provide some high level details, in case you might be interested in tackling this (or if someone else see the comment as well):
|
I would like to add that I'm keen on this proposed functionality - |
Even better-- just |
Would be really awesome to get this fixed |
Hey folks, just wanted to say that I left a couple of suggestions before on how this feature could be implemented in pylint. As previously mentioned, we'll get to it someday, but as far as it concerns me, I don't have enough time on my plate for implementing this feature. A PR from someone else could definitely speed this up! |
As we do depend on this a little bit it would be awesome to get it tackled and I would even enable our gsoc student to have a look at it. What would be helpful would be any insight or mentorship he could get, as he obviously doesn't know the codebase and it seems to be quiet a deep change? |
Hey @razzeee That sounds like a great first step. I can offer mentorship on this issue if someone wants to write the code for it. I suggested an initial step in this comment #352 (comment) but I would be happy to write a more in-depth comment on what exactly needs to be changed. |
@PCManticore After looking into this and following the comment I was able to figure it out. In astroid/modutils.py - L472 we are stoping the
Here src_directory = "Example" Solution: def get_module_files(src_directory, blacklist, list_all=False, init=False):
files = []
for directory, dirnames, filenames in os.walk(src_directory):
if directory in blacklist:
continue
_handle_blacklist(blacklist, dirnames, filenames)
if not list_all and not init:
dirnames[:] = ()
continue
for filename in filenames:
if _is_python_file(filename):
src = os.path.join(directory, filename)
files.append(src)
return files Here After this modification
Please tell me whether I am on right track or not. Now the thing I was not able to understand was your refrence to pylint/utils - L800. What will I have to do there ? Also can you tell me which file will I have to change to make this a command line flag |
Hey @mzfr That sounds about right! Thanks for looking into this! Regarding the reference from utils.py:800, I have no idea! The code has changed since I last linked it. Regarding the file to change, you can take a look into |
@PCManticore ok so I am going to ignore utils:800 now. (('init',
{'default' : 'True','type': 'yn' 'metavar' : '<y_or_n>',
'help' : 'When set to False - not processing directories without __init__.py'
'when set to True - processing directories without __init__.py'}), This is what I think let me know whether should I add any |
This is what @PCManticore linked to back when he referenced to that line https://github.com/PyCQA/pylint/blob/5d40a07684be7ed6dbaa54e49c3d436005a533bf/pylint/utils.py#L800 |
@mzfr Sounds about right! One thing though, |
I think this issue may also prevent pylint from being used in black style (RegEx string)[tool.pylint]
include = '(lib|test)/.+\.py$' isort style (list of dirs)[tool.pylint]
src_paths = [
"lib",
"test",
] |
Is there a way to contribute to a bounty or something? I would happy to buy a pizza for whoever implements this. |
You can create a bounty on issue hunt for example. Maybe what you refer to as a 'pizza' is equivalent to multiple days of work in another country than the one you live in. :) If pylint is not set up for Issue Hunt let me know, I'll do it. |
I've started to use A simple example:
You of course cannot put this file discovery in |
Thanks to @matusvalo this will be available in pylint 2.13.0. There's a follow up discussion concerning the possibility to launch pylint without argument in the current directory in #5701, please cast your vote if you have an opinion on the issue :) |
Now I will wait for pizza :-D (just kidding) |
Thanks! Tell me how you would like to receive a coupon or money and it will be done. I can do SEPA transfers. [email protected] |
@felixvd If you mean it, you can use github sponsor : https://github.com/sponsors/matusvalo 😄 It's matched by github the first year so it might very well even be two (2) pizzas in the end 🎉 |
Or even better donate to pylint project or maintainers of pylint. The money will be better spent for you if you are using pylint. My message was pure joke. I could not resist to post it :-D |
The more you know! I hadn't heard of that, guess it's worth using. I sent you half of @matusvalo 's pizza fee, but his sponsor page does not have a one-time contribution option. @matusvalo maybe you could set that up? |
@matusvalo I tried this out, the option is kind of hidden in |
You need to set up a connected bank account with Stripe Express, which is probably the reason why it's not turned on by default 😉 Looking at @matusvalo's profile, they have turned it on though 😄 |
@felixvd I prefer not to enable one-time payments (I have some practical reasons for that). If you still want to do one-time contribution, I have sent you my IBAN over the e-mail ([email protected]). |
This PR migrates from autosynth to [owl bot](https://github.com/googleapis/repo-automation-bots/tree/master/packages/owl-bot). owl bot will save time for maintainers as it will automatically open PRs when there are updates in [googleapis-gen](https://github.com/googleapis/googleapis-gen/tree/master/google) without requiring maintainers to run `synthtool` to build the client from protos. Additionally, similar to autosynth, PRs will be automatically opened when there are template updates.
…#362) There is [an issue](https://github.com/googleapis/python-firestore/blob/master/owlbot.py#L60) in the `owlbot.py` file added in pylint-dev#352 in that [s.remove_staging_dirs()](https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L309) should only be called once after all the files are copied over. [get_staging_dirs()](https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L280) will only return staging directories that exist.
Originally reported by: Buck Evan (BitBucket: bukzor, GitHub: @bukzor?)
It would make things easier for me to use pylint in CI if I could simply say
pylint .
in order to tell pylint to look at all my files.flake8/pep8 already have this behavior. They make it configurable via a filepatterns config (default
*.py
) and an exclude config (default.svn,CVS,.bzr,.hg,.git,__pycache__
).Discussion from #pylint:
The text was updated successfully, but these errors were encountered: