[pyupgrade] Enable rule triggering for stub files (UP043)#20027
[pyupgrade] Enable rule triggering for stub files (UP043)#20027dylwil3 merged 4 commits intoastral-sh:mainfrom
pyupgrade] Enable rule triggering for stub files (UP043)#20027Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| UP043 | 265 | 265 | 0 | 0 | 0 |
|
This looks right to me but since there's (necessarily) such a huge diff in the ecosystem it would be great if e.g. @AlexWaygood could confirm it's all good (and shouldn't be in preview)? |
|
@AlexWaygood Could you please review PR? |
ntBre
left a comment
There was a problem hiding this comment.
Thanks! I just had a couple of nits but otherwise I agree with Dylan. This looks good, but I'd like to get quick confirmation from Alex that it makes sense to apply this rule to stubs. I think that's the case based on his comment here but good to double check.
I also think this should probably be a preview change. It's a straightforward code fix, but expanding the scope of the rule to a new file type seems pretty significant to me.
There was a problem hiding this comment.
Thanks for identifying one of the files from the issue! However, I'd probably lean toward a stripped-down example over including a file verbatim from another project since the specifics of the code aren't really that important. We could even just duplicate UP043.py and call it UP043.pyi, I think.
| /// ## What it does | ||
| /// Checks for unnecessary default type arguments for `Generator` and | ||
| /// `AsyncGenerator` on Python 3.13+. | ||
| /// `AsyncGenerator` on Python 3.13+ or stubs. |
There was a problem hiding this comment.
| /// `AsyncGenerator` on Python 3.13+ or stubs. | |
| /// `AsyncGenerator` on Python 3.13+ or in stubs. |
3c5b75d to
c190105
Compare
|
Yup, it makes sense for this to always be enabled for stubs regardless of Python version. I agree with Brent that this should probably be gated behind preview initially. The change was requested by a typeshed maintainer, and I'm also a typeshed maintainer, so I wouldn't worry too much about the impact on typeshed (it's not going to take us by surprise! 😄) -- but there are other authors of stubs out there, and it could take them by surprise to have such a big expansion of the rule go directly into a stable rule without a preview-only period first. |
|
(Sorry for the delayed response -- been a bit busy recently with a house move and other things!) |
|
@AlexWaygood Thanks! |
…-sh#20027) ## Summary Resolves astral-sh#20011 Implemented alternative triggering condition for rule [`UP043`](https://docs.astral.sh/ruff/rules/unnecessary-default-type-args/) based on requirements outlined in [issue astral-sh#20011](astral-sh#20011) ## Test Plan Created .pyi file to ensure triggering the rule --------- Co-authored-by: Igor Drokin <drokinii1017@gmail.com> Co-authored-by: dylwil3 <dylwil3@gmail.com>
Summary
Resolves #20011
Implemented alternative triggering condition for rule
UP043based on requirements outlined in issue #20011Test Plan
Created .pyi file to ensure triggering the rule