Skip to content

Guard type-hint providers and infer X | Y union annotations - #908

Open
marlon-costa-dc wants to merge 6 commits into
python-rope:masterfrom
marlon-costa-dc:pr/type-hinting-guards
Open

marlon-costa-dc wants to merge 6 commits into
python-rope:masterfrom
marlon-costa-dc:pr/type-hinting-guards

Conversation

@marlon-costa-dc

Copy link
Copy Markdown
Contributor

Two small type-hinting fixes:

  1. get_class_with_attr_name and the PEP 484 type-comment provider index pyname.assignments[0] unconditionally, which raises AttributeError/ IndexError when a non-AssignedName pyname (a parameter, a match capture, ...) reaches them. Guard with isinstance(pyname, AssignedName).

  2. The or/| hint evaluator raised NotImplementedError, so completions on union-annotated names lost both alternatives. Evaluate to a synthesized class exposing the attributes of each alternative; this un-xfails test_hint_or and adds coverage for first-alternative attributes.

type_hinting_test: 100 passed locally on 3.13.

…e pynames

The inheritance provider hands DefinedName pynames (import rebinds) to
the type-comment provider, which unconditionally reads pyname.assignments
and raises AttributeError; return None so inference falls through to the
next composite provider.
The or/| type-hint evaluator raised NotImplementedError, so every
completion on a union-annotated name lost both alternatives. Evaluate
to a synthesized class exposing the attributes of each alternative,
which also un-xfails the hint_or completion test.
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.44%. Comparing base (ff8a306) to head (5ceaab9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #908   +/-   ##
=======================================
  Coverage   95.44%   95.44%           
=======================================
  Files         134      134           
  Lines       26910    26935   +25     
=======================================
+ Hits        25685    25709   +24     
- Misses       1225     1226    +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 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>

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.

2 participants