ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Split UP007 Union and Optional to two individual rules

Open blueraft opened this issue 1 year ago • 1 comments

Resolves https://github.com/astral-sh/ruff/issues/4858

Summary

  • [x] Drop Optional support from UP007 in preview mode

  • [x] Add new rule in preview for use of Optional

  • [ ] Add documentation about the transition to both rules -> I have added some documentation regarding this to the rustdoc, @zanieb do you want me to add this somewhere else too?

Test Plan

  • cargo test
  • The updated docs render correctly.

blueraft avatar May 12 '24 11:05 blueraft

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+4 -1183 violations, +0 -0 fixes in 5 projects; 39 projects unchanged)

PlasmaPy/PlasmaPy (+2 -0 violations, +0 -0 fixes)

+ src/plasmapy/particles/particle_class.py:2516:42: RUF100 [*] Unused `noqa` directive (non-enabled: `UP007`)
+ src/plasmapy/particles/particle_collections.py:616:76: RUF100 [*] Unused `noqa` directive (non-enabled: `UP007`)
apache/airflow (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ airflow/utils/log/logging_mixin.py:75:52: RUF100 [*] Unused `noqa` directive (non-enabled: `UP007`)
+ airflow/utils/log/logging_mixin.py:77:41: RUF100 [*] Unused `noqa` directive (non-enabled: `UP007`)
demisto/content (+0 -1169 violations, +0 -0 fixes)

- Packs/AMP/Integrations/AMPv2/AMPv2.py:3240:11: UP007 [*] Use `X | Y` for type annotations
- Packs/AMP/Integrations/AMPv2/AMPv2.py:3241:16: UP007 [*] Use `X | Y` for type annotations
- Packs/AMP/Integrations/AMPv2/AMPv2.py:3242:12: UP007 [*] Use `X | Y` for type annotations
- Packs/ANYRUN/Integrations/ANYRUN/ANYRUN.py:756:24: UP007 [*] Use `X | Y` for type annotations
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:34:105: UP007 [*] Use `X | Y` for type annotations
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:35:48: UP007 [*] Use `X | Y` for type annotations
- Packs/AccentureCTI_Feed/Integrations/ACTIIndicatorFeed/ACTIIndicatorFeed.py:122:60: UP007 [*] Use `X | Y` for type annotations
- Packs/AccentureCTI_Feed/Integrations/ACTIIndicatorFeed/ACTIIndicatorFeed.py:134:33: UP007 [*] Use `X | Y` for type annotations
- Packs/AgariPhishingDefense/Integrations/AgariPhishingDefense/AgariPhishingDefense.py:586:6: UP007 [*] Use `X | Y` for type annotations
- Packs/AgariPhishingDefense/Integrations/AgariPhishingDefense/AgariPhishingDefense.py:622:6: UP007 [*] Use `X | Y` for type annotations
- Packs/AlienVault_OTX/Integrations/AlienVault_OTX_v2/AlienVault_OTX_v2.py:92:56: UP007 [*] Use `X | Y` for type annotations
- Packs/ApiModules/Scripts/NGINXApiModule/NGINXApiModule_test.py:90:16: UP007 [*] Use `X | Y` for type annotations
- Packs/AppNovi/Integrations/appNovi/appNovi.py:49:26: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:255:30: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:255:53: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:255:71: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:436:33: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocus/FeedAutofocus.py:380:58: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocus/FeedAutofocus.py:407:81: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocus/FeedAutofocus.py:487:74: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:105:58: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:120:81: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:141:84: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:179:74: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:66:91: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:131:52: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:166:40: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:390:19: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:391:15: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:392:19: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:61:80: UP007 [*] Use `X | Y` for type annotations
- Packs/Binalyze/Integrations/BinalyzeAIR/BinalyzeAIR.py:18:61: UP007 [*] Use `X | Y` for type annotations
- Packs/Binalyze/Integrations/BinalyzeAIR/BinalyzeAIR.py:49:87: UP007 [*] Use `X | Y` for type annotations
- Packs/Binalyze/Integrations/BinalyzeAIR/BinalyzeAIR.py:84:59: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:1109:75: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:1217:47: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:1444:88: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2066:77: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2108:96: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2165:86: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2214:84: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2262:83: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2310:12: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2310:21: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2359:85: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2439:85: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2487:12: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2487:21: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2542:83: UP007 [*] Use `X | Y` for type annotations
... 1120 additional changes omitted for project
latchbio/latch (+0 -13 violations, +0 -0 fixes)

- latch/registry/record.py:180:57: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:182:64: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:207:53: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:209:60: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:242:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:248:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:278:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:284:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:303:41: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:74:15: UP007 Use `X | Y` for type annotations
... 3 additional changes omitted for project
rotki/rotki (+0 -1 violations, +0 -0 fixes)

- packaging/docker/entrypoint.py:54:32: UP007 [*] Use `X | Y` for type annotations
Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
UP007 1183 0 1183 0 0
RUF100 4 4 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+4 -882 violations, +0 -0 fixes in 4 projects; 40 projects unchanged)

apache/airflow (+4 -2 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/utils/log/logging_mixin.py:1:1: D100 Missing docstring in public module
- airflow/utils/log/logging_mixin.py:1:1: D100 Missing docstring in public module
+ airflow/utils/log/logging_mixin.py:209:9: ANN201 Missing return type annotation for public function `isatty`
- airflow/utils/log/logging_mixin.py:209:9: ANN201 Missing return type annotation for public function `isatty`
+ airflow/utils/log/logging_mixin.py:75:52: RUF100 [*] Unused `noqa` directive (unused: `UP007`)
+ airflow/utils/log/logging_mixin.py:77:41: RUF100 [*] Unused `noqa` directive (unused: `UP007`)
demisto/content (+0 -866 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- Packs/AMP/Integrations/AMPv2/AMPv2.py:3240:11: UP007 [*] Use `X | Y` for type annotations
- Packs/AMP/Integrations/AMPv2/AMPv2.py:3241:16: UP007 [*] Use `X | Y` for type annotations
- Packs/AMP/Integrations/AMPv2/AMPv2.py:3242:12: UP007 [*] Use `X | Y` for type annotations
- Packs/ANYRUN/Integrations/ANYRUN/ANYRUN.py:756:24: UP007 [*] Use `X | Y` for type annotations
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:34:105: UP007 [*] Use `X | Y` for type annotations
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:35:48: UP007 [*] Use `X | Y` for type annotations
- Packs/ApiModules/Scripts/NGINXApiModule/NGINXApiModule_test.py:90:16: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:255:30: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:255:53: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:255:71: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/AutoFocusTagsFeed/AutoFocusTagsFeed.py:436:33: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocus/FeedAutofocus.py:380:58: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocus/FeedAutofocus.py:407:81: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocus/FeedAutofocus.py:487:74: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:105:58: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:120:81: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:141:84: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:179:74: UP007 [*] Use `X | Y` for type annotations
- Packs/AutoFocus/Integrations/FeedAutofocusDaily/FeedAutofocusDaily.py:66:91: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:131:52: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:166:40: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:390:19: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:391:15: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:392:19: UP007 [*] Use `X | Y` for type annotations
- Packs/Base/Scripts/ValidateContent/ValidateContent.py:61:80: UP007 [*] Use `X | Y` for type annotations
- Packs/Binalyze/Integrations/BinalyzeAIR/BinalyzeAIR.py:18:61: UP007 [*] Use `X | Y` for type annotations
- Packs/Binalyze/Integrations/BinalyzeAIR/BinalyzeAIR.py:49:87: UP007 [*] Use `X | Y` for type annotations
- Packs/Binalyze/Integrations/BinalyzeAIR/BinalyzeAIR.py:84:59: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:1109:75: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:1217:47: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:1444:88: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2066:77: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2108:96: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2310:12: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:2487:12: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:777:30: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:777:62: UP007 [*] Use `X | Y` for type annotations
- Packs/BmcHelixRemedyForce/Integrations/BmcHelixRemedyForce/BmcHelixRemedyForce.py:955:85: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:1027:74: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:1094:34: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:1790:21: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:1793:16: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:1800:13: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:266:43: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:287:49: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:563:49: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:563:91: UP007 [*] Use `X | Y` for type annotations
- Packs/Box/Integrations/BoxV2/BoxV2.py:564:41: UP007 [*] Use `X | Y` for type annotations
... 818 additional changes omitted for project
latchbio/latch (+0 -13 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- latch/registry/record.py:180:57: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:182:64: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:207:53: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:209:60: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:242:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:248:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:278:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:284:10: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:303:41: UP007 Use `X | Y` for type annotations
- latch/registry/record.py:74:15: UP007 Use `X | Y` for type annotations
... 3 additional changes omitted for project
rotki/rotki (+0 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- packaging/docker/entrypoint.py:54:32: UP007 [*] Use `X | Y` for type annotations
Changes by rule (4 rules affected)

code total + violation - violation + fix - fix
UP007 880 0 880 0 0
D100 2 1 1 0 0
ANN201 2 1 1 0 0
RUF100 2 2 0 0 0

github-actions[bot] avatar May 12 '24 11:05 github-actions[bot]

any progress?

plusls avatar Aug 09 '24 04:08 plusls

Do you intend to continue the work on this PR soon? If not, I can take it over.

InSyncWithFoo avatar Jan 01 '25 13:01 InSyncWithFoo

@InSyncWithFoo Feel free to take over, thanks!

blueraft avatar Jan 02 '25 12:01 blueraft

Closing, because we merged #15313

MichaReiser avatar Jan 07 '25 14:01 MichaReiser