Skip to content

regression in analyze regarding stdlib shadowing with PEP420 packages #28274

Description

@emillon

Summary

Hi,

I've noticed a regression in ruff analyze graph.

In a PEP-420 namespace package, imports from stdlib are resolved to sibling modules (when these exist).

Concretely here's a MWE:

# pyproject.toml
[tool.ruff]
src = ["src"]
namespace-packages = ["src/example"]
# src/example/main.py
from typing import Any

x: Any = 1
# src/example/typing.py
y = 3

Results:

% uvx ruff@0.14.9 analyze graph
warning: `ruff analyze graph` is experimental and may change without warning
{
  "src/example/main.py": [],
  "src/example/typing.py": []
}
% uvx ruff@0.14.10 analyze graph
warning: `ruff analyze graph` is experimental and may change without warning
{
  "src/example/main.py": [
    "src/example/typing.py"
  ],
  "src/example/typing.py": []
}

(same behavior in 0.14.10 and 0.16.5)

This might be related to #21817, which makes sense given that adding an empty __init__.pyi fixes it.

What do you think?
Thanks!

Version

0.16.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzeRelated to Ruff analyze functionalitybugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions