-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect PLR1701
to SIM101
#12021
Merged
Merged
Redirect PLR1701
to SIM101
#12021
Conversation
This file contains 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
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PLR1701 | 11 | 0 | 11 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+0 -11 violations, +0 -0 fixes in 2 projects; 48 projects unchanged)
apache/airflow (+0 -3 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- airflow/providers/microsoft/azure/hooks/msgraph.py:327:12: PLR1701 [*] Merge `isinstance` calls: `isinstance(data, (BytesIO, bytes, str))` - airflow/serialization/pydantic/dag.py:45:9: PLR1701 [*] Merge `isinstance` calls - airflow/serialization/pydantic/taskinstance.py:70:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(x, (BaseOperator, MappedOperator))`
demisto/content (+0 -8 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
- Packs/ANYRUN/Integrations/ANYRUN/ANYRUN.py:196:16: PLR1701 Merge `isinstance` calls: `isinstance(val, dict | list)` - Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector.py:33:12: PLR1701 Merge `isinstance` calls: `isinstance(obj, date | datetime)` - Packs/Base/Scripts/DBotMLFetchData/DBotMLFetchData.py:187:23: PLR1701 Merge `isinstance` calls: `isinstance(x, bool | str)` - Packs/Base/Scripts/DBotMLFetchData/DBotMLFetchData.py:192:37: PLR1701 Merge `isinstance` calls: `isinstance(v, bool | str)` - Packs/Base/Scripts/DBotTrainClustering/DBotTrainClustering.py:422:8: PLR1701 Merge `isinstance` calls: `isinstance(obj, list | str)` - Packs/BluecatAddressManager/Integrations/BluecatAddressManager/BluecatAddressManager.py:256:12: PLR1701 Merge `isinstance` calls - Packs/ExpanseV2/Scripts/ExpanseEvidenceDynamicSection/ExpanseEvidenceDynamicSection.py:15:8: PLR1701 Merge `isinstance` calls: `isinstance(v, float | int | str)` - Packs/TOPdesk/Integrations/TOPdesk/TOPdesk.py:577:16: PLR1701 Merge `isinstance` calls: `isinstance(value, bool | str)`
Changes by rule (1 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PLR1701 | 11 | 0 | 11 | 0 | 0 |
charliermarsh
approved these changes
Jun 25, 2024
Merged
MichaReiser
pushed a commit
that referenced
this pull request
Jun 27, 2024
## Summary This rule removes `PLR1701` and redirects it to `SIM101`. In addition to that, the `SIM101` autofix has been fixed to add padding if required. ### `PLR1701` has bugs It also seems that the implementation of `PLR1701` is incorrect in multiple scenarios. For example, the following code snippet: ```py # There are two _different_ variables `a` and `b` if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): pass # There's another condition `or 1` if isinstance(self.k, int) or isinstance(self.k, float) or 1: pass ``` is fixed to: ```py # Fixed to only considering variable `a` if isinstance(a, (float, int)): pass # The additional condition is not present in the fix if isinstance(self.k, (float, int)): pass ``` Playground: https://play.ruff.rs/6cfbdfb7-f183-43b0-b59e-31e728b34190 ## Documentation Preview ### `PLR1701` <img width="1397" alt="Screenshot 2024-06-25 at 11 14 40" src="https://github.com/astral-sh/ruff/assets/67177269/779ee84d-7c4d-4bb8-a3a4-c2b23a313eba"> ## Test Plan Remove the test cases for `PLR1701`, port the padding test case to `SIM101` and update the snapshot.
MichaReiser
pushed a commit
that referenced
this pull request
Jun 27, 2024
## Summary This rule removes `PLR1701` and redirects it to `SIM101`. In addition to that, the `SIM101` autofix has been fixed to add padding if required. ### `PLR1701` has bugs It also seems that the implementation of `PLR1701` is incorrect in multiple scenarios. For example, the following code snippet: ```py # There are two _different_ variables `a` and `b` if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): pass # There's another condition `or 1` if isinstance(self.k, int) or isinstance(self.k, float) or 1: pass ``` is fixed to: ```py # Fixed to only considering variable `a` if isinstance(a, (float, int)): pass # The additional condition is not present in the fix if isinstance(self.k, (float, int)): pass ``` Playground: https://play.ruff.rs/6cfbdfb7-f183-43b0-b59e-31e728b34190 ## Documentation Preview ### `PLR1701` <img width="1397" alt="Screenshot 2024-06-25 at 11 14 40" src="https://github.com/astral-sh/ruff/assets/67177269/779ee84d-7c4d-4bb8-a3a4-c2b23a313eba"> ## Test Plan Remove the test cases for `PLR1701`, port the padding test case to `SIM101` and update the snapshot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This rule removes
PLR1701
and redirects it toSIM101
.In addition to that, the
SIM101
autofix has been fixed to add padding if required.PLR1701
has bugsIt also seems that the implementation of
PLR1701
is incorrect in multiple scenarios. For example, the following code snippet:is fixed to:
Playground: https://play.ruff.rs/6cfbdfb7-f183-43b0-b59e-31e728b34190
Documentation Preview
PLR1701
Test Plan
Remove the test cases for
PLR1701
, port the padding test case toSIM101
and update the snapshot.