Skip to content

Conversation

@blueraft
Copy link
Contributor

Resolves #4858

Summary

  • Drop Optional support from UP007 in preview mode

  • 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 blueraft changed the title Split UP007 from Union and Optional to two individual rules Split UP007 Union and Optional to two individual rules May 12, 2024
@blueraft blueraft marked this pull request as draft May 12, 2024 11:45
@blueraft blueraft marked this pull request as ready for review May 12, 2024 11:46
@github-actions
Copy link
Contributor

github-actions bot commented May 12, 2024

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

@@ -0,0 +1,41 @@
import typing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest a test case of the form List[Optional[str, int]] ?

To be sure the rule detect also nested Optional. Or it is already the case? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I've added a test case for nested Optional. A test case for nested Union was already there, so I didn't modify that.

@zanieb zanieb self-requested a review May 14, 2024 14:54
@plusls
Copy link

plusls commented Aug 9, 2024

any progress?

@MichaReiser MichaReiser added this to the v0.7 milestone Aug 19, 2024
@AlexWaygood AlexWaygood modified the milestones: v0.7, v0.8 Oct 17, 2024
@AlexWaygood AlexWaygood modified the milestones: v0.8, v0.9 Nov 18, 2024
@InSyncWithFoo
Copy link
Contributor

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

@blueraft
Copy link
Contributor Author

blueraft commented Jan 2, 2025

@InSyncWithFoo Feel free to take over, thanks!

@MichaReiser
Copy link
Member

Closing, because we merged #15313

@MichaReiser MichaReiser closed this Jan 7, 2025
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.

UP007: opt out of Optional

6 participants