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

Folder analysis fails if '__init__.py' is not present #2108

Closed
Stevoisiak opened this issue May 16, 2018 · 8 comments
Closed

Folder analysis fails if '__init__.py' is not present #2108

Stevoisiak opened this issue May 16, 2018 · 8 comments

Comments

@Stevoisiak
Copy link
Contributor

Stevoisiak commented May 16, 2018

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)

Steps to reproduce

  1. Create a project with the following folder structure

    project
        hello.py
        goodbye.py
    
  2. Analyze the folder with Pylint

    pylint C:\Temp\project
    

Current behavior

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)

Expected behavior

Pylint should analyze all files in the folder without raising an error.

pylint --version output

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)]

Extra information

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.

@Stevoisiak Stevoisiak changed the title Folder analysis fails if __init__.py is not present ("No such file or directory") Folder analysis fails if '__init__.py' is not present May 16, 2018
@PCManticore
Copy link
Contributor

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

@sztomi
Copy link

sztomi commented May 28, 2018

@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)?

@Stevoisiak
Copy link
Contributor Author

Stevoisiak commented May 29, 2018

@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.

@ClaytonSmith
Copy link

ClaytonSmith commented Jun 18, 2019

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.

@MattLupino
Copy link

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?

@lyellread
Copy link

I also have this issue, with very similar initial parameters. Is there any plan to fix this?

vla22 pushed a commit to ska-telescope/lmc-base-classes that referenced this issue Mar 19, 2020
@KharchenkoDmitriy
Copy link

Work usually well, but fails if xxx folder has xxx.py module.
Have renamed xxx.py to xxx_config.py and it works.

@calvinloveland
Copy link

calvinloveland commented Jan 17, 2024

If anyone ends up here like I have: I found that --recursive y makes pylint act like I expect

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

8 participants