Commit 42ebf36
The current UP007 "Fix safety" paragraph reads "This rule's fix is
marked as unsafe, as it may lead to runtime errors when alongside
libraries that rely on runtime type annotations, like Pydantic, on
Python versions prior to Python 3.10..." The filer of astral-sh#17062 hit the fix
on Python 3.10+ (where the source explicitly marks the fix safe) and was
confused about what the docs were warning about.
In the thread, ntBre clarified the actual semantics ("the fix is marked
unsafe on Python versions prior to Python 3.10 but safe on and after
3.10") and pjonsson suggested flipping the sentence around. I rewrote
the paragraph to mirror the code: the fix is safe when target is 3.10+
and there are no comments, otherwise it's unsafe for one of two reasons
(pre-3.10 runtime introspection like Pydantic can `TypeError` on `X |
Y`, or comments inside the original would be dropped during rewrite).
The unusual-inner-expression caveat is kept. I applied the same rewrite
to UP045's docstring because it had the same wording.
Docstring-only. `cargo dev generate-all` and `uvx prek run --from-ref
main` both pass.
fixes astral-sh#17062
---------
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
1 parent 1651c2d commit 42ebf36
1 file changed
Lines changed: 12 additions & 12 deletions
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
0 commit comments