Skip to content

Honor namespace-package precedence when resolving imports - #910

Open
marlon-costa-dc wants to merge 11 commits into
python-rope:masterfrom
marlon-costa-dc:pr/namespace-precedence
Open

marlon-costa-dc wants to merge 11 commits into
python-rope:masterfrom
marlon-costa-dc:pr/namespace-precedence

Conversation

@marlon-costa-dc

Copy link
Copy Markdown
Contributor

_find_module_in_folder resolved the first dotted component in the first source folder and stopped. With PEP 420 namespace packages spread across source folders, the wrong portion wins: a regular package or module in any source folder must beat a namespace directory, and namespace portions must combine across folders.

This resolves dotted names per component across all source folders (regular packages/modules first, namespace portions combined), and keeps relative module resolution restricted to the current folder.

pycoretest: 137 passed (9 new precedence tests) locally on 3.13.

Marlon Costa and others added 2 commits October 18, 2026 09:05
Project.find_module() resolved each dotted component inside a single
folder at a time, so a namespace-package directory (a folder without
__init__.py) shadowed a regular module or package living in a later
source folder, and namespace portions were never combined.

Resolve each name component across all candidate folders instead:
regular packages and plain modules win over namespace directories
regardless of folder order, while namespace portions are collected
across folders so their submodules remain reachable.  Relative module
resolution keeps searching only the given folder.

Adapted to 1.15.0 from the internal change: only the resolution
semantics and its pycore tests are carried over.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.46%. Comparing base (ff8a306) to head (939210e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #910      +/-   ##
==========================================
+ Coverage   95.44%   95.46%   +0.01%     
==========================================
  Files         134      134              
  Lines       26910    26997      +87     
==========================================
+ Hits        25685    25773      +88     
+ Misses       1225     1224       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

marlon-costa-dc and others added 7 commits October 19, 2026 04:41
…sions

Grant metadata-only task checker its checks permission
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Temporary directories may be reached through a symlink (/var on macOS)
or a short name (RUNNER~1 on Windows), while rope reports real paths.
The previous merge brought this file from the contributor fork's master.
marlon-costa-dc added a commit to marlon-costa-dc/rope that referenced this pull request Nov 7, 2026
Our open python-rope/rope PRs carry tests that the fork release absorbed
in behaviour but not in tests. Each passes against the current code:
- python-rope#908 test_assignment_hints_ignore_names_that_are_not_assigned
- python-rope#909 test_scope_region_rejects_decorator_without_source_positions,
       test_scope_region_rejects_decorator_without_source_marker
- python-rope#920 test_hint_param_on_a_hierarchy_python_refuses
- python-rope#910 test_find_module_skips_python_path_files
- python-rope#844 test_format_string_region_without_closing_quote_is_rejected

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lieryan

lieryan commented Nov 18, 2026

Copy link
Copy Markdown
Member

@marlon-costa-dc can you please stop merging master only to resolve a CHANGELOG conflicts. You're spamming notifications and clogging Github Actions runner every time you do that.

If there's any real merge conflicts, please continue resolving them, but your pull requests will not be reviewed any faster by spamming the project with all these notifications. I'll address the CHANGELOG merge conflicts when I finished reviewing them.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

3 participants