-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Correct the warning for Rule E712 in pytest assertion #18328
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
Conversation
|
| 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 |
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me let me update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
@MichaReiser i have updated the code as you suggest is it good to go now?? |
MichaReiser
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
* 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)
* 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) ...
Summary
closes #18272
Test Plan
i have run simple tests via
cargo testandcargo insta testalso done review via
cargo insta review