2

I am using pylint version 2.16.1 on Python version 3.9 on windows.

I need to execute pylint for all the files of non ".py" extension (example .abc extension) in directory and its subdirectories. I could not find an option as part of the pylint to perform the same.

I could run pylint on a specific file of non py extension (example .abc extension) and it successfully gives the output. For example: pylint my_file_name.abc

But if I try to run pylint with wildcard '*.abc" , it gives an error:

************* Module *.abc *.abc:1:0: F0001: No module named *.abc (fatal)

Note: I do have the init.py in the folder I am trying run from the folder.

1 Answers1

1

Looks like there is not a direct approach in pylint (at-least in windows) to run it on all the files of non py extension with a wild-cards. But pylint does work on the list of files mentioned in a single command and provide the consolidated score.

The approach is to have batch file which can first parse the the directory (recursively) for all the files of the desired extension. The filenames are stored in the variable (not an array) in a concatenated approach. pylint command can then be executed on this variable of filenames.

The following snippet of code shows the approach:

@echo off
setlocal enabledelayedexpansion

set "abc_files_path=my_project_path\*.abc"

set files=

set "fileCount=0"
for /f "delims=" %%f in ('dir /b /s %abc_files_path%') do (
set "files[!fileCount!]=%%f"

set "files=!files! %%f"
)

pylint %files%
  • For many files I got an error that the line is too long. If you want to use this you might need to check for the fileCount and apply pylint in batches. – Stefan Apr 14 '23 at 07:43
  • I tried this approach to check file naming convention for non-python files. However, this did not work with pylint. For an alternative see https://softwarerecs.stackexchange.com/questions/86819/how-to-enforce-python-file-naming-convention-e-g-snake-case-for-all-files-in – Stefan Apr 14 '23 at 07:43