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

Fix FBT001 false negative with unions and optional #7501

Conversation

JonathanPlasse
Copy link
Contributor

Summary

In the spirit of flake8-boolean-trap, any positional argument that can accept a boolean should raise FBT001.
Raise FBT001 for all annotations that accept booleans (e.g. Optional[bool], Union[int, bool]).

Test Plan

Add a fixture, with an annotation using |, Optional, and Union, and containing a boolean.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 18, 2023

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+214 -0 violations, +0 -0 fixes in 41 projects)

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

ruff check --no-cache --exit-zero --select ALL

+ airflow/callbacks/callback_requests.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/callbacks/callback_requests.py:80:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_external_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_virtualenv.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/external_python.py:38:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python.py:63:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python_virtualenv.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/short_circuit.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/lineage/entities.py:73:21: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/baseoperator.py:1482:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:2869:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:3836:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:460:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:101:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:98:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:99:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:212:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:379:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/taskinstance.py:2599:9: FBT001 Boolean-typed positional argument in function definition
... 69 additional changes omitted for project

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

ruff check --no-cache --exit-zero --select ALL

+ src/bokeh/embed/util.py:183:65: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/server/tornado.py:608:25: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/settings.py:167:18: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/util/token.py:207:32: FBT001 Boolean-typed positional argument in function definition
+ src/typings/selenium/webdriver/firefox/options.pyi:3:41: FBT001 Boolean-typed positional argument in function definition

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

ruff check --no-cache --exit-zero --select ALL

+ analytics/lib/counts.py:301:5: FBT001 Boolean-typed positional argument in function definition
+ analytics/views/support.py:169:5: FBT001 Boolean-typed positional argument in function definition
+ corporate/tests/test_stripe.py:448:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/create_user.py:413:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_settings.py:400:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_status.py:11:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:159:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:164:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/event_schema.py:1572:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:1931:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:2392:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/management.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1728:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1753:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1775:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/notification_data.py:266:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/streams.py:94:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:1345:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:825:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_runner.py:188:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/webhooks/git.py:98:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/tests/test_realm_export.py:124:13: FBT001 Boolean-typed positional argument in function definition
+ zerver/tornado/django_api.py:41:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:21:32: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:46:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:50:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:101:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:112:5: FBT001 Boolean-typed positional argument in function definition
... 92 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FBT001 214 214 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+209 -0 violations, +0 -0 fixes in 41 projects)

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

ruff check --no-cache --exit-zero --select ALL --preview

+ airflow/callbacks/callback_requests.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/callbacks/callback_requests.py:80:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_external_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_virtualenv.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/external_python.py:38:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python.py:63:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python_virtualenv.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/short_circuit.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/lineage/entities.py:73:21: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/baseoperator.py:1482:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:2869:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:3836:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:460:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:101:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:98:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:99:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:212:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:379:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/taskinstance.py:2599:9: FBT001 Boolean-typed positional argument in function definition
... 64 additional changes omitted for project

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

ruff check --no-cache --exit-zero --select ALL --preview

+ src/bokeh/embed/util.py:183:65: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/server/tornado.py:608:25: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/settings.py:167:18: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/util/token.py:207:32: FBT001 Boolean-typed positional argument in function definition
+ src/typings/selenium/webdriver/firefox/options.pyi:3:41: FBT001 Boolean-typed positional argument in function definition

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

ruff check --no-cache --exit-zero --select ALL --preview

+ analytics/lib/counts.py:301:5: FBT001 Boolean-typed positional argument in function definition
+ analytics/views/support.py:169:5: FBT001 Boolean-typed positional argument in function definition
+ corporate/tests/test_stripe.py:448:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/create_user.py:413:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_settings.py:400:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_status.py:11:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:159:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:164:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/event_schema.py:1572:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:1931:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:2392:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/management.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1728:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1753:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1775:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/notification_data.py:266:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/streams.py:94:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:1345:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:825:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_runner.py:188:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/webhooks/git.py:98:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/tests/test_realm_export.py:124:13: FBT001 Boolean-typed positional argument in function definition
+ zerver/tornado/django_api.py:41:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:21:32: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:46:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:50:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:101:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:112:5: FBT001 Boolean-typed positional argument in function definition
... 92 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FBT001 209 209 0 0 0

@JonathanPlasse
Copy link
Contributor Author

JonathanPlasse commented Sep 18, 2023

This could introduce a lot of new positives.
Is it possible to have a preview of rules behavior change?

@charliermarsh charliermarsh added the preview Related to preview mode features label Sep 19, 2023
@JonathanPlasse JonathanPlasse force-pushed the fix-fbt001-false-negative-union-of-bool branch 2 times, most recently from 6465010 to 47fc41d Compare October 17, 2023 11:38
Comment on lines 104 to 107
Expr::Constant(ast::ExprConstant {
value: Constant::Str(ast::StringConstant { value, .. }),
..
}) => value == "bool",
Copy link
Member

Choose a reason for hiding this comment

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

With #8064 merged, you'll need to update this to use Expr::StringLiteral instead:

Suggested change
Expr::Constant(ast::ExprConstant {
value: Constant::Str(ast::StringConstant { value, .. }),
..
}) => value == "bool",
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => value == "bool",

@JonathanPlasse JonathanPlasse force-pushed the fix-fbt001-false-negative-union-of-bool branch from 47fc41d to d755162 Compare November 2, 2023 07:46
@JonathanPlasse JonathanPlasse force-pushed the fix-fbt001-false-negative-union-of-bool branch from d755162 to e356126 Compare November 2, 2023 09:07
Copy link
Contributor

github-actions bot commented Nov 2, 2023

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+214 -0 violations, +0 -0 fixes in 41 projects)

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

ruff check --no-cache --exit-zero --select ALL

+ airflow/callbacks/callback_requests.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/callbacks/callback_requests.py:80:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_external_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_virtualenv.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/external_python.py:38:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python.py:63:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python_virtualenv.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/short_circuit.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/lineage/entities.py:73:21: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/baseoperator.py:1482:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:2869:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:3836:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:460:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:101:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:98:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:99:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:212:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:379:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/taskinstance.py:2599:9: FBT001 Boolean-typed positional argument in function definition
... 69 additional changes omitted for project

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

ruff check --no-cache --exit-zero --select ALL

+ src/bokeh/embed/util.py:183:65: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/server/tornado.py:608:25: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/settings.py:167:18: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/util/token.py:207:32: FBT001 Boolean-typed positional argument in function definition
+ src/typings/selenium/webdriver/firefox/options.pyi:3:41: FBT001 Boolean-typed positional argument in function definition

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

ruff check --no-cache --exit-zero --select ALL

+ analytics/lib/counts.py:301:5: FBT001 Boolean-typed positional argument in function definition
+ analytics/views/support.py:169:5: FBT001 Boolean-typed positional argument in function definition
+ corporate/tests/test_stripe.py:448:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/create_user.py:413:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_settings.py:400:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_status.py:11:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:159:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:164:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/event_schema.py:1572:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:1931:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:2392:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/management.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1728:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1753:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1775:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/notification_data.py:266:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/streams.py:94:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:1345:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:825:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_runner.py:188:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/webhooks/git.py:98:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/tests/test_realm_export.py:124:13: FBT001 Boolean-typed positional argument in function definition
+ zerver/tornado/django_api.py:41:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:21:32: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:46:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:50:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:101:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:112:5: FBT001 Boolean-typed positional argument in function definition
... 92 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FBT001 214 214 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+209 -0 violations, +0 -0 fixes in 41 projects)

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

ruff check --no-cache --exit-zero --select ALL --preview

+ airflow/callbacks/callback_requests.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/callbacks/callback_requests.py:80:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_external_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_virtualenv.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/external_python.py:38:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python.py:63:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python_virtualenv.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/short_circuit.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/lineage/entities.py:73:21: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/baseoperator.py:1482:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:2869:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:3836:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:460:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:101:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:98:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:99:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:212:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:379:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/taskinstance.py:2599:9: FBT001 Boolean-typed positional argument in function definition
... 64 additional changes omitted for project

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

ruff check --no-cache --exit-zero --select ALL --preview

+ src/bokeh/embed/util.py:183:65: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/server/tornado.py:608:25: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/settings.py:167:18: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/util/token.py:207:32: FBT001 Boolean-typed positional argument in function definition
+ src/typings/selenium/webdriver/firefox/options.pyi:3:41: FBT001 Boolean-typed positional argument in function definition

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

ruff check --no-cache --exit-zero --select ALL --preview

+ analytics/lib/counts.py:301:5: FBT001 Boolean-typed positional argument in function definition
+ analytics/views/support.py:169:5: FBT001 Boolean-typed positional argument in function definition
+ corporate/tests/test_stripe.py:448:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/create_user.py:413:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_settings.py:400:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_status.py:11:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:159:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:164:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/event_schema.py:1572:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:1931:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:2392:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/management.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1728:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1753:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1775:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/notification_data.py:266:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/streams.py:94:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:1345:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:825:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_runner.py:188:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/webhooks/git.py:98:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/tests/test_realm_export.py:124:13: FBT001 Boolean-typed positional argument in function definition
+ zerver/tornado/django_api.py:41:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:21:32: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:46:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:50:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:101:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:112:5: FBT001 Boolean-typed positional argument in function definition
... 92 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FBT001 209 209 0 0 0

@JonathanPlasse
Copy link
Contributor Author

How should I proceed to make this behavior change only for the preview mode?

@charliermarsh
Copy link
Member

@JonathanPlasse - I think you could change match_annotation_to_bool to take the preview flag as argument, and fork internally?

}
}
_ => false,
};
Copy link
Member

Choose a reason for hiding this comment

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

@dhruvmanila - Is it possible to use TypingTarget for this?

Copy link
Contributor

github-actions bot commented Nov 12, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+214 -0 violations, +0 -0 fixes in 41 projects)

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

ruff check --no-cache --exit-zero --select ALL --preview

+ airflow/callbacks/callback_requests.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/callbacks/callback_requests.py:80:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_external_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_python.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/branch_virtualenv.py:36:46: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/external_python.py:38:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python.py:63:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/python_virtualenv.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/decorators/short_circuit.py:37:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/lineage/entities.py:73:21: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/baseoperator.py:1489:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:2875:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:3842:5: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dag.py:460:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:101:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:98:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagbag.py:99:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:213:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/dagrun.py:380:9: FBT001 Boolean-typed positional argument in function definition
+ airflow/models/taskinstance.py:2606:9: FBT001 Boolean-typed positional argument in function definition
... 67 additional changes omitted for project

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

ruff check --no-cache --exit-zero --select ALL --preview

+ src/bokeh/embed/util.py:183:65: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/server/tornado.py:608:25: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/settings.py:172:18: FBT001 Boolean-typed positional argument in function definition
+ src/bokeh/util/token.py:207:32: FBT001 Boolean-typed positional argument in function definition
+ src/typings/selenium/webdriver/firefox/options.pyi:3:41: FBT001 Boolean-typed positional argument in function definition
+ tests/unit/bokeh/test_settings.py:131:33: FBT001 Boolean-typed positional argument in function definition
+ tests/unit/bokeh/test_settings.py:135:39: FBT001 Boolean-typed positional argument in function definition

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

ruff check --no-cache --exit-zero --select ALL --preview

+ analytics/lib/counts.py:306:5: FBT001 Boolean-typed positional argument in function definition
+ analytics/views/support.py:172:5: FBT001 Boolean-typed positional argument in function definition
+ corporate/tests/test_stripe.py:443:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/create_user.py:414:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_settings.py:400:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/actions/user_status.py:11:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:159:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/create_user.py:164:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/event_schema.py:1561:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:1931:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/export.py:2392:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/management.py:120:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1743:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1768:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/message.py:1790:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/notification_data.py:266:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/streams.py:94:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:1356:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_classes.py:825:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_runner.py:188:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/webhooks/git.py:98:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/tests/test_realm_export.py:124:13: FBT001 Boolean-typed positional argument in function definition
+ zerver/tornado/django_api.py:41:9: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:21:32: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:46:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/events_register.py:50:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:101:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/views/realm.py:112:5: FBT001 Boolean-typed positional argument in function definition
... 92 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FBT001 214 214 0 0 0

@charliermarsh charliermarsh merged commit 776eb87 into astral-sh:main Nov 12, 2023
17 checks passed
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Nov 12, 2023
@JonathanPlasse JonathanPlasse deleted the fix-fbt001-false-negative-union-of-bool branch November 12, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FBT001 Boolean trap surprising false negative with bool | None
3 participants