Skip to content
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

Show negated condition in needless-bool diagnostics #10854

Merged
merged 1 commit into from Apr 10, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

Closes #10843.

@charliermarsh charliermarsh added the bug Something isn't working label Apr 10, 2024
Copy link

github-actions bot commented Apr 10, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+7 -7 violations, +0 -0 fixes in 3 projects; 41 projects unchanged)

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

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

- airflow/migrations/env.py:33:5: SIM103 Return the condition directly
+ airflow/migrations/env.py:33:5: SIM103 Return the negated condition directly
- scripts/ci/pre_commit/check_integrations_list.py:113:9: SIM103 Return the condition `j in ["Description", "Identifier"]` directly
+ scripts/ci/pre_commit/check_integrations_list.py:113:9: SIM103 Return the condition `not j in ["Description", "Identifier"]` directly

demisto/content (+4 -4 violations, +0 -0 fixes)

+ Packs/CimTrak-SystemIntegrityAssurance/Integrations/CimTrak/CimTrak.py:1606:5: SIM103 Return the condition `not (value.lower() == "false" or value == "0")` directly
- Packs/CimTrak-SystemIntegrityAssurance/Integrations/CimTrak/CimTrak.py:1606:5: SIM103 Return the condition `value.lower() == "false" or value == "0"` directly
- Packs/ContentManagement/Scripts/ConfigurationSetup/ConfigurationSetup.py:221:5: SIM103 Return the condition directly
+ Packs/ContentManagement/Scripts/ConfigurationSetup/ConfigurationSetup.py:221:5: SIM103 Return the negated condition directly
- Packs/Malwarebytes/Integrations/Malwarebytes/Malwarebytes.py:1432:13: SIM103 Return the condition `data.get("statusCode") == 201` directly
+ Packs/Malwarebytes/Integrations/Malwarebytes/Malwarebytes.py:1432:13: SIM103 Return the condition `data.get('statusCode') == 201` directly
- Packs/TrendMicroDDA/Integrations/TrendMicroDDA/TrendMicroDDA.py:126:5: SIM103 Return the condition `binary == '0'` directly
+ Packs/TrendMicroDDA/Integrations/TrendMicroDDA/TrendMicroDDA.py:126:5: SIM103 Return the condition `not binary == "0"` directly

zulip/zulip (+1 -1 violations, +0 -0 fixes)

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

+ zproject/backends.py:628:5: SIM103 Return the condition `bool(find_ldap_users_by_email(email))` directly
- zproject/backends.py:628:5: SIM103 Return the condition `find_ldap_users_by_email(email)` directly

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
SIM103 14 7 7 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+97 -97 violations, +0 -0 fixes in 10 projects; 34 projects unchanged)

apache/airflow (+24 -24 violations, +0 -0 fixes)

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

+ airflow/configuration.py:1309:13: SIM103 Return the condition `not value is None` directly
- airflow/configuration.py:1309:13: SIM103 Return the condition `value is None` directly
+ airflow/dag_processing/manager.py:1248:9: SIM103 Return the condition `not self._num_run < self._max_runs` directly
- airflow/dag_processing/manager.py:1248:9: SIM103 Return the condition `self._num_run < self._max_runs` directly
- airflow/migrations/env.py:33:5: SIM103 Return the condition directly
+ airflow/migrations/env.py:33:5: SIM103 Return the negated condition directly
- airflow/models/taskinstance.py:385:5: SIM103 Return the condition `isinstance(value, (bytearray, bytes, str))` directly
+ airflow/models/taskinstance.py:385:5: SIM103 Return the condition `not isinstance(value, (bytearray, bytes, str))` directly
- airflow/providers/amazon/aws/hooks/s3.py:649:13: SIM103 Return the condition directly
+ airflow/providers/amazon/aws/hooks/s3.py:649:13: SIM103 Return the negated condition directly
+ airflow/providers/amazon/aws/sensors/athena.py:97:9: SIM103 Return the condition `not state in self.INTERMEDIATE_STATES` directly
- airflow/providers/amazon/aws/sensors/athena.py:97:9: SIM103 Return the condition `state in self.INTERMEDIATE_STATES` directly
... 36 additional changes omitted for project

bokeh/bokeh (+1 -1 violations, +0 -0 fixes)

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

+ examples/server/app/server_auth/auth.py:40:9: SIM103 Return the condition `bool(username == "bokeh" and password == "bokeh")` directly
- examples/server/app/server_auth/auth.py:40:9: SIM103 Return the condition `username == "bokeh" and password == "bokeh"` directly

demisto/content (+25 -25 violations, +0 -0 fixes)

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

- Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py:763:9: SIM103 Return the condition `RDL is None` directly
+ Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py:763:9: SIM103 Return the negated condition directly
+ Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py:778:9: SIM103 Return the condition `not not self._valid(self.rcs)` directly
- Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py:778:9: SIM103 Return the condition `not self._valid(self.rcs)` directly
+ Packs/Active_Directory_Query/Integrations/Active_Directory_Query/Active_Directory_Query.py:347:5: SIM103 Return the condition `bool(entries.get('flat'))` directly
- Packs/Active_Directory_Query/Integrations/Active_Directory_Query/Active_Directory_Query.py:347:5: SIM103 Return the condition `entries.get('flat')` directly
- Packs/Base/Scripts/DBotTrainClustering/DBotTrainClustering.py:540:5: SIM103 Return the condition `not 1 < n_labels < n_samples` directly
+ Packs/Base/Scripts/DBotTrainClustering/DBotTrainClustering.py:540:5: SIM103 Return the condition `not not 1 < n_labels < n_samples` directly
+ Packs/CheckPhish/Integrations/CheckPhish/CheckPhish.py:144:5: SIM103 Return the condition `bool(res and res['status'] == DONE_STATUS)` directly
- Packs/CheckPhish/Integrations/CheckPhish/CheckPhish.py:144:5: SIM103 Return the condition `res and res['status'] == DONE_STATUS` directly
+ Packs/CimTrak-SystemIntegrityAssurance/Integrations/CimTrak/CimTrak.py:1606:5: SIM103 Return the condition `not (value.lower() == "false" or value == "0")` directly
- Packs/CimTrak-SystemIntegrityAssurance/Integrations/CimTrak/CimTrak.py:1606:5: SIM103 Return the condition `value.lower() == "false" or value == "0"` directly
... 38 additional changes omitted for project

freedomofpress/securedrop (+6 -6 violations, +0 -0 fixes)

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

+ journalist_gui/journalist_gui/SecureDropUpdater.py:23:5: SIM103 Return the condition `not pwd_flag == "NP"` directly
- journalist_gui/journalist_gui/SecureDropUpdater.py:23:5: SIM103 Return the condition `pwd_flag == "NP"` directly
+ securedrop/pretty_bad_protocol/_parsers.py:1008:9: SIM103 Return the condition `bool(self.fingerprint)` directly
- securedrop/pretty_bad_protocol/_parsers.py:1008:9: SIM103 Return the condition `self.fingerprint` directly
- securedrop/pretty_bad_protocol/_parsers.py:1321:9: SIM103 Return the condition `len(self.fingerprints) == 0` directly
+ securedrop/pretty_bad_protocol/_parsers.py:1321:9: SIM103 Return the condition `not len(self.fingerprints) == 0` directly
- securedrop/pretty_bad_protocol/_parsers.py:1425:9: SIM103 Return the condition `len(self.fingerprints) == 0` directly
+ securedrop/pretty_bad_protocol/_parsers.py:1425:9: SIM103 Return the condition `not len(self.fingerprints) == 0` directly
+ securedrop/pretty_bad_protocol/_parsers.py:1788:9: SIM103 Return the condition `bool(self.ok)` directly
- securedrop/pretty_bad_protocol/_parsers.py:1788:9: SIM103 Return the condition `self.ok` directly
... 2 additional changes omitted for project

milvus-io/pymilvus (+5 -5 violations, +0 -0 fixes)

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

- pymilvus/client/check.py:166:5: SIM103 Return the condition `(end_date - start_date).days < 0` directly
+ pymilvus/client/check.py:166:5: SIM103 Return the condition `not (end_date - start_date).days < 0` directly
- pymilvus/client/check.py:20:5: SIM103 Return the condition `not is_legal_host(a[0]) or not is_legal_port(a[1])` directly
+ pymilvus/client/check.py:20:5: SIM103 Return the negated condition directly
- pymilvus/client/check.py:27:5: SIM103 Return the condition directly
+ pymilvus/client/check.py:27:5: SIM103 Return the negated condition directly
- pymilvus/orm/collection.py:1438:9: SIM103 Return the condition directly
+ pymilvus/orm/collection.py:1438:9: SIM103 Return the negated condition directly
- pymilvus/orm/iterator.py:458:9: SIM103 Return the condition `cached_page is None or len(cached_page) < count` directly
+ pymilvus/orm/iterator.py:458:9: SIM103 Return the negated condition directly

mlflow/mlflow (+9 -9 violations, +0 -0 fixes)

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

- mlflow/sklearn/utils.py:929:9: SIM103 Return the condition `not len(c.__abstractmethods__)` directly
+ mlflow/sklearn/utils.py:929:9: SIM103 Return the condition `not not len(c.__abstractmethods__)` directly
- mlflow/tracking/_tracking_service/utils.py:25:5: SIM103 Return the condition `_tracking_uri or MLFLOW_TRACKING_URI.get()` directly
+ mlflow/tracking/_tracking_service/utils.py:25:5: SIM103 Return the condition `bool(_tracking_uri or MLFLOW_TRACKING_URI.get())` directly
- mlflow/transformers/__init__.py:1465:5: SIM103 Return the condition directly
+ mlflow/transformers/__init__.py:1465:5: SIM103 Return the negated condition directly
- mlflow/utils/logging_utils.py:101:9: SIM103 Return the condition directly
+ mlflow/utils/logging_utils.py:101:9: SIM103 Return the negated condition directly
- mlflow/utils/search_utils.py:1199:9: SIM103 Return the condition directly
+ mlflow/utils/search_utils.py:1199:9: SIM103 Return the negated condition directly
... 8 additional changes omitted for project

pypa/cibuildwheel (+1 -1 violations, +0 -0 fixes)

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

- cibuildwheel/projectfiles.py:42:5: SIM103 Return the condition `len(consts) != 1` directly
+ cibuildwheel/projectfiles.py:42:5: SIM103 Return the condition `not len(consts) != 1` directly

reflex-dev/reflex (+1 -1 violations, +0 -0 fixes)

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

+ reflex/utils/telemetry.py:85:5: SIM103 Return the condition `not should_skip_compile()` directly
- reflex/utils/telemetry.py:85:5: SIM103 Return the condition `should_skip_compile()` directly

scikit-build/scikit-build (+1 -1 violations, +0 -0 fixes)

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

- skbuild/setuptools_wrap.py:348:5: SIM103 Return the condition `"sdist" in given_commands and cmake_with_sdist` directly
+ skbuild/setuptools_wrap.py:348:5: SIM103 Return the condition directly

zulip/zulip (+24 -24 violations, +0 -0 fixes)

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

- scripts/lib/zulip_tools.py:546:5: SIM103 Return the condition `"posix" in os.name and os.geteuid() == 0` directly
+ scripts/lib/zulip_tools.py:546:5: SIM103 Return the condition `bool("posix" in os.name and os.geteuid() == 0)` directly
- zerver/decorator.py:1025:9: SIM103 Return the condition `not user_has_device(user)` directly
+ zerver/decorator.py:1025:9: SIM103 Return the condition directly
- zerver/lib/avatar.py:144:5: SIM103 Return the condition directly
+ zerver/lib/avatar.py:144:5: SIM103 Return the negated condition directly
- zerver/lib/compatibility.py:157:5: SIM103 Return the condition directly
+ zerver/lib/compatibility.py:157:5: SIM103 Return the negated condition directly
- zerver/lib/message.py:1425:5: SIM103 Return the condition directly
+ zerver/lib/message.py:1425:5: SIM103 Return the negated condition directly
+ zerver/lib/message.py:1439:5: SIM103 Return the condition `not user_profile.realm != message.get_realm()` directly
- zerver/lib/message.py:1439:5: SIM103 Return the condition `user_profile.realm != message.get_realm()` directly
... 36 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
SIM103 194 97 97 0 0

@charliermarsh charliermarsh enabled auto-merge (squash) April 10, 2024 04:23
@charliermarsh charliermarsh merged commit dbf8d0c into main Apr 10, 2024
17 checks passed
@charliermarsh charliermarsh deleted the charlie/negate branch April 10, 2024 04:29
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIM103 return condition directly incorrect error message
1 participant