When analyzing a folder, Pylint will fail with "No such file or directory" (parse-error) if the folder does not contain an __init__.py file.
Ironically, this means Pylint will fail if you try to analyze the Pylint repository.
C:\Windows\System32>pylint C:\Temp\pylint-master
No config file found, using default configuration
*************
F: 1, 0: error while code parsing: Unable to load file C:\Temp\pylint-master\__init__.py:
[Errno 2] No such file or directory: 'C:\\Temp\\pylint-master\\__init__.py' (parse-error)
Create a project with the following folder structure
project
hello.py
goodbye.py
Analyze the folder with Pylint
pylint C:\Temp\project
Folder analysis will fail.
C:\Windows\System32>pylint C:\Temp\project
No config file found, using default configuration
*************
F: 1, 0: error while code parsing: Unable to load file C:\Temp\project\__init__.py:
[Errno 2] No such file or directory: 'C:\\Temp\\project\\__init__.py' (parse-error)
Pylint should analyze all files in the folder without raising an error.
No config file found, using default configuration
pylint 1.9.0,
astroid 1.6.3
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
This issue is likely related to #842. It appears this issue was fixed when analyzing individual files, but is still present when analyzing folders.
__init__.py was made optional in Python 3.3.
Duplicate of #352 We currently don't support analyzing directories with no __init__ files in them, as we consider all the directories passed to CLI as packages. This will change in the future once #352 is fixed
@PCManticore Isn't that different though? In Python3.3+ directories don't need __init__.py to be considered packages. Can't pylint do the same (i.e. not fail when there is no __init__.py but consider the directory a package)?
@sztomi The specific example I used for this issue was a root project folder, not a package folder.
I have not tested what will happen if pylint analyzes a package directory without an __init__.py file.
So what's the status of this issue? I can't run pylint at my project's root and I don't understand why that's not supported.
I'm also interested in a workaround for this using the pylint module. Is there a way to stop getting this error when using epylint.py_run() on a PyCharm project? Would the workaround possibly use --ignore=__init__.py or something like that?
I also have this issue, with very similar initial parameters. Is there any plan to fix this?
Most helpful comment
So what's the status of this issue? I can't run pylint at my project's root and I don't understand why that's not supported.