Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

PLS doesn't resolve relative paths correctly #510

Closed

Description

@erictraut

The analyzer sometimes does not resolve relative paths correctly. See the screen shot below.

screen shot 2018-12-26 at 1 53 04 am

The problem appears to be in PathResolverSnapshot.TryFindName which contains the following lines of code:

if (lastEdge.End.IsModule) {
    return false;
}

I don't understand why this logic is needed. When I comment out these three lines, the relative paths resolve correctly and other imports also appear to resolve as expected.

Activity

  1. MikhailArkhipov commented on Dec 26, 2018

    @MikhailArkhipov

    Alexander Sher (@AlexanderSher) owns the import subsystem.

  2. AlexanderSher commented on Jan 2, 2019

    @AlexanderSher
    Contributor

    I don't understand why this logic is needed.

    It is required for the case when there is a folder with the name of the module.
    For example, for the following file structure:

    ├─ package
       ├─ module
       │  └─ submodule.py
       ├─ module.py
       └─ test.py
    

    and test.py:

    from .module.submodule import TEST
    

    import should be highlighted as invalid import.

    In your case, what is the value of lastEdge.End.ModulePath in that piece of code?

    if (lastEdge.End.IsModule) {
        return false;
    }
  3. erictraut commented on Jan 2, 2019

    @erictraut
    Author

    In the example you gave above, if the module directory contained an __init__.py file, the import from test.py should succeed. Would you expect lastEdge.End.IsModule to evaluate to false if __init__.py is present?

    To answer your question. lastEdge.End.IsModule evaluates to true in my case, which is what causes the .exceptions and '.image_builder` imports to be incorrectly flagged as errors.

  4. added 2 commits that reference this issue on Jan 2, 2019
    ab15e1e
    23f6d67
  5. added 2 commits that reference this issue on Feb 4, 2019
    00aebad
    a5b6e5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions