[ty] Preserve qualifiers when accessing attributes on unions/intersections by sharkdp · Pull Request #20114 · astral-sh/ruff (original) (raw)

@sharkdp added the ty

Multi-file analysis & type inference

label

Aug 27, 2025

@sharkdp sharkdp changed the title[ty] Fix attribute access on intersection types [ty] Preserve qualifiers when accessing attributes on unions/intersections

Aug 27, 2025

@sharkdp

sharkdp

sharkdp

@sharkdp sharkdp marked this pull request as ready for review

August 27, 2025 15:20

@sharkdp sharkdp marked this pull request as ready for review

August 27, 2025 15:28

AlexWaygood

@sharkdp sharkdp deleted the david/attribute-access-on-intersections-again branch

August 27, 2025 18:01

carljm added a commit to leandrobbraga/ruff that referenced this pull request

Aug 27, 2025

@carljm

second-ed pushed a commit to second-ed/ruff that referenced this pull request

Sep 9, 2025

@sharkdp @second-ed

…tions (astral-sh#20114)

Summary

Properly preserve type qualifiers when accessing attributes on unions and intersections. This is a prerequisite for astral-sh#19579.

Also fix a completely wrong implementation of map_with_boundness_and_qualifiers. It now closely follows map_with_boundness (just above).

Test Plan

I thought about it, but didn't find any easy way to test this. This only affected Type::member. Things like validation of attribute writes (where type qualifiers like ClassVar and Final are important) were already handling things correctly.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})