Correct the warning for Rule E712 in pytest assertion#18328
Merged
MichaReiser merged 4 commits intoastral-sh:mainfrom May 28, 2025
Merged
Correct the warning for Rule E712 in pytest assertion#18328MichaReiser merged 4 commits intoastral-sh:mainfrom
MichaReiser merged 4 commits intoastral-sh:mainfrom
Conversation
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| E712 | 18 | 9 | 9 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+9 -9 violations, +0 -0 fixes in 2 projects; 53 projects unchanged)
binary-husky/gpt_academic (+2 -2 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
- request_llms/oai_std_model_template.py:230:41: E712 Avoid equality comparisons to `False`; use `if not reasoning:` for false checks + request_llms/oai_std_model_template.py:230:41: E712 Avoid equality comparisons to `False`; use `not reasoning:` for false checks - request_llms/oai_std_model_template.py:376:41: E712 Avoid equality comparisons to `False`; use `if not reasoning:` for false checks + request_llms/oai_std_model_template.py:376:41: E712 Avoid equality comparisons to `False`; use `not reasoning:` for false checks
qdrant/qdrant-client (+7 -7 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
- qdrant_client/grpc/collections_pb2.py:806:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/collections_pb2.py:806:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks - qdrant_client/grpc/collections_service_pb2.py:23:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/collections_service_pb2.py:23:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks - qdrant_client/grpc/json_with_int_pb2.py:58:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/json_with_int_pb2.py:58:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks - qdrant_client/grpc/points_pb2.py:1295:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/points_pb2.py:1295:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks - qdrant_client/grpc/points_service_pb2.py:23:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/points_service_pb2.py:23:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks - qdrant_client/grpc/qdrant_pb2.py:41:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/qdrant_pb2.py:41:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks - qdrant_client/grpc/snapshots_service_pb2.py:103:4: E712 Avoid equality comparisons to `False`; use `if not _descriptor._USE_C_DESCRIPTORS:` for false checks + qdrant_client/grpc/snapshots_service_pb2.py:103:4: E712 Avoid equality comparisons to `False`; use `not _descriptor._USE_C_DESCRIPTORS:` for false checks
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| E712 | 18 | 9 | 9 | 0 | 0 |
MichaReiser
requested changes
May 27, 2025
| 5 5 | if res != False: | ||
|
|
||
| E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `if res:` for truth checks | ||
| E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `assert res:` for truth checks |
Member
There was a problem hiding this comment.
The message now is incorrect for if statements. It's also incorrect for assert because of the trailing colon.
I think the proper suggestion here is to suggest: use res for truth checks and use not res
Contributor
Author
There was a problem hiding this comment.
sounds good to me let me update
Contributor
Author
|
@MichaReiser i have updated the code as you suggest is it good to go now?? |
dcreager
added a commit
that referenced
this pull request
May 28, 2025
* main: [ty] Support ephemeral uv virtual environments (#18335) Add a `ViolationMetadata::rule` method (#18234) Return `DiagnosticGuard` from `Checker::report_diagnostic` (#18232) [flake8_use_pathlib]: Replace os.symlink with Path.symlink_to (PTH211) (#18337) [ty] Support cancellation and retry in the server (#18273) [ty] Synthetic function-like callables (#18242) [ty] Support publishing diagnostics in the server (#18309) Add Autofix for ISC003 (#18256) [`pyupgrade`]: new rule UP050 (`useless-class-metaclass-type`) (#18334) [pycodestyle] Make `E712` suggestion not assume a context (#18328)
carljm
added a commit
to MatthewMckee4/ruff
that referenced
this pull request
May 28, 2025
* main: (246 commits) [ty] Simplify signature types, use them in `CallableType` (astral-sh#18344) [ty] Support ephemeral uv virtual environments (astral-sh#18335) Add a `ViolationMetadata::rule` method (astral-sh#18234) Return `DiagnosticGuard` from `Checker::report_diagnostic` (astral-sh#18232) [flake8_use_pathlib]: Replace os.symlink with Path.symlink_to (PTH211) (astral-sh#18337) [ty] Support cancellation and retry in the server (astral-sh#18273) [ty] Synthetic function-like callables (astral-sh#18242) [ty] Support publishing diagnostics in the server (astral-sh#18309) Add Autofix for ISC003 (astral-sh#18256) [`pyupgrade`]: new rule UP050 (`useless-class-metaclass-type`) (astral-sh#18334) [pycodestyle] Make `E712` suggestion not assume a context (astral-sh#18328) put similar dunder-call tests next to each other (astral-sh#18343) [ty] Derive `PartialOrd, Ord` for `KnownInstanceType` (astral-sh#18340) [ty] Simplify `Type::try_bool()` (astral-sh#18342) [ty] Simplify `Type::normalized` slightly (astral-sh#18339) [ty] Move arviz off the list of selected primer projects (astral-sh#18336) [ty] Add --config-file CLI arg (astral-sh#18083) [ty] Tell the user why we inferred a certain Python version when reporting version-specific syntax errors (astral-sh#18295) [ty] Implement implicit inheritance from `Generic[]` for PEP-695 generic classes (astral-sh#18283) [ty] Add hint if async context manager is used in non-async with statement (astral-sh#18299) ...
This file contains hidden or 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
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
closes #18272
Test Plan
i have run simple tests via
cargo testandcargo insta testalso done review via
cargo insta review