8000 pylsp is confused by a script having the same name as a package it imports · Issue #638 · python-lsp/python-lsp-server · GitHub
[go: up one dir, main page]

Skip to content

pylsp is confused by a script having the same name as a package it imports #638

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

Open
jy-lefort opened this issue May 1, 2025 · 0 comments

Comments

@jy-lefort
Copy link

Consider the following file tree:

foo.py
foo/__init__.py

With contents:

# foo.py
from foo import *
bar()
# foo/__init__.py
def bar():
    print("bar")

This is legit Python and as expected, running python foo.py prints the string bar.

However, pylsp is confused by the fact that foo.py and the foo module have the same name, and won't visit the definition of bar() from foo.py. Renaming foo.py to foo2.py works around the issue.

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

1 participant
0