Skip to content

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

Open
@jy-lefort

Description

@jy-lefort

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions