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

Consider single element subscript expr for implicit optional #5717

Merged
merged 14 commits into from
Jul 13, 2023

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jul 12, 2023

Summary

Consider single element subscript expr for implicit optional.

On main, the cases where there is only a single element in the subscript
list was giving false positives such as for the following:

typing.Union[None]
typing.Literal[None]

Test Plan

cargo test

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@dhruvmanila dhruvmanila marked this pull request as draft July 12, 2023 18:07
@github-actions
Copy link
Contributor

github-actions bot commented Jul 12, 2023

PR Check Results

Ecosystem

ℹ️ ecosystem check detected changes. (+56, -0, 0 error(s))

airflow (+28, -0)

+ airflow/decorators/base.py:333:16: PLR1714 Consider merging multiple comparisons: `ttype in (dict, Dict)`. Use a `set` if the elements are hashable.
+ airflow/decorators/task_group.py:150:13: PLR1714 Consider merging multiple comparisons: `v.kind in (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD)`. Use a `set` if the elements are hashable.
+ airflow/models/dagrun.py:704:12: PLR1714 Consider merging multiple comparisons: `self._state in (DagRunState.FAILED, DagRunState.SUCCESS)`. Use a `set` if the elements are hashable.
+ airflow/providers/amazon/aws/hooks/redshift_data.py:115:18: PLR1714 Consider merging multiple comparisons: `status in ("FAILED", "ABORTED")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/hooks/kubernetes_engine.py:127:16: PLR1714 Consider merging multiple comparisons: `operation.status in (Operation.Status.RUNNING, Operation.Status.PENDING)`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/bigquery_dts.py:373:20: PLR1714 Consider merging multiple comparisons: `state in (TransferState.FAILED, TransferState.CANCELLED)`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/bigquery_dts.py:395:12: PLR1714 Consider merging multiple comparisons: `event["status"] in ("failed", "cancelled")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/dataflow.py:708:12: PLR1714 Consider merging multiple comparisons: `event["status"] in ("error", "stopped")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/dataflow.py:893:12: PLR1714 Consider merging multiple comparisons: `event["status"] in ("error", "stopped")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/dataproc.py:1795:12: PLR1714 Consider merging multiple comparisons: `event["status"] in ("failed", "error")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/dataproc.py:1920:12: PLR1714 Consider merging multiple comparisons: `event["status"] in ("failed", "error")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/kubernetes_engine.py:166:12: PLR1714 Consider merging multiple comparisons: `status in ("failed", "error")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/operators/kubernetes_engine.py:373:12: PLR1714 Consider merging multiple comparisons: `status in ("failed", "error")`. Use a `set` if the elements are hashable.
+ airflow/providers/google/cloud/triggers/kubernetes_engine.py:202:22: PLR1714 Consider merging multiple comparisons: `status in (Operation.Status.RUNNING, Operation.Status.PENDING)`. Use a `set` if the elements are hashable.
+ airflow/providers/google/common/hooks/base_google.py:101:16: PLR1714 Consider merging multiple comparisons: `exception.resp.status in (429, 409)`. Use a `set` if the elements are hashable.
+ airflow/www/fab_security/manager.py:616:12: PLR1714 Consider merging multiple comparisons: `provider in ("github", "githublocal")`. Use a `set` if the elements are hashable.
+ airflow/www/views.py:3999:24: PLR1714 Consider merging multiple comparisons: `dep.dependency_type in ("dag", "dataset")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/utils/host_info_utils.py:38:8: PLR1714 Consider merging multiple comparisons: `os in ("linux", "darwin")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/utils/host_info_utils.py:48:8: PLR1714 Consider merging multiple comparisons: `os in ("linux", "darwin")`. Use a `set` if the elements are hashable.
+ dev/provider_packages/prepare_provider_packages.py:742:12: PLR1714 Consider merging multiple comparisons: `ex.returncode in (128, 2)`. Use a `set` if the elements are hashable.
+ docker_tests/test_docker_compose_quick_start.py:90:16: PLR1714 Consider merging multiple comparisons: `health_status in ("healthy", "no-check")`. Use a `set` if the elements are hashable.
+ helm_tests/airflow_aux/test_basic_helm_chart.py:42:12: PLR1714 Consider merging multiple comparisons: `version in ("2.3.2", "default")`. Use a `set` if the elements are hashable.
+ scripts/ci/pre_commit/pre_commit_check_lazy_logging.py:44:17: PLR1714 Consider merging multiple comparisons: `self.cur_node.func.value.id in ("logger", "logging", "log")`. Use a `set` if the elements are hashable.
+ scripts/ci/pre_commit/pre_commit_json_schema.py:145:8: PLR1714 Consider merging multiple comparisons: `default not in (instance, "See values.yaml")`. Use a `set` if the elements are hashable.
+ tests/jobs/test_backfill_job.py:1286:16: PLR1714 Consider merging multiple comparisons: `ti.task_id in ("leave1", "leave2")`. Use a `set` if the elements are hashable.
+ tests/jobs/test_triggerer_job.py:203:16: PLR1714 Consider merging multiple comparisons: `job_runner.capacity in (input_str, 1000)`. Use a `set` if the elements are hashable.
+ tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py:372:16: PLR1714 Consider merging multiple comparisons: `target in ("_all", "")`. Use a `set` if the elements are hashable.
+ tests/providers/google/cloud/operators/test_bigquery.py:1829:16: PLR1714 Consider merging multiple comparisons: `missing_param.value.args[0] in (expected, expected1)`. Use a `set` if the elements are hashable.

bokeh (+4, -0)

+ src/bokeh/server/tornado.py:619:12: PLR1714 Consider merging multiple comparisons: `mode in ("server", "server-dev")`. Use a `set` if the elements are hashable.
+ tests/unit/bokeh/embed/test_server__embed.py:215:16: PLR1714 Consider merging multiple comparisons: `r in ("&foo=10&bar=baz", "&bar=baz&foo=10")`. Use a `set` if the elements are hashable.
+ tests/unit/bokeh/embed/test_server__embed.py:222:16: PLR1714 Consider merging multiple comparisons: `r in ("&foo=10&bar=baz", "&bar=baz&foo=10")`. Use a `set` if the elements are hashable.
+ tests/unit/bokeh/test_objects.py:575:16: PLR1714 Consider merging multiple comparisons: `i in (('a', 1), ('b', 2), ('c', 3))`. Use a `set` if the elements are hashable.

typeshed (+2, -0)

+ stdlib/builtins.pyi:867:27: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`
+ stdlib/typing.pyi:758:23: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`

zulip (+22, -0)

+ analytics/views/user_activity.py:63:12: PLR1714 Consider merging multiple comparisons: `k in ("name", "user_profile_id")`. Use a `set` if the elements are hashable.
+ tools/lib/sanity_check.py:17:12: PLR1714 Consider merging multiple comparisons: `user_name not in ("vagrant", "zulipdev")`. Use a `set` if the elements are hashable.
+ zerver/actions/create_realm.py:102:9: PLR1714 Consider merging multiple comparisons: `realm.org_type in (Realm.ORG_TYPES["education_nonprofit"]["id"], Realm.ORG_TYPES["education"]["id"])`. Use a `set` if the elements are hashable.
+ zerver/actions/create_realm.py:220:13: PLR1714 Consider merging multiple comparisons: `realm.org_type in (Realm.ORG_TYPES["education_nonprofit"]["id"], Realm.ORG_TYPES["education"]["id"])`. Use a `set` if the elements are hashable.
+ zerver/actions/custom_profile_fields.py:113:9: PLR1714 Consider merging multiple comparisons: `field.field_type in (CustomProfileField.SELECT, CustomProfileField.EXTERNAL_ACCOUNT)`. Use a `set` if the elements are hashable.
+ zerver/actions/custom_profile_fields.py:65:9: PLR1714 Consider merging multiple comparisons: `custom_profile_field.field_type in (CustomProfileField.SELECT, CustomProfileField.EXTERNAL_ACCOUNT)`. Use a `set` if the elements are hashable.
+ zerver/lib/email_notifications.py:528:24: PLR1714 Consider merging multiple comparisons: `m["trigger"] in (NotificationTriggers.MENTION, NotificationTriggers.STREAM_WILDCARD_MENTION, NotificationTriggers.STREAM_WILDCARD_MENTION_IN_FOLLOWED_TOPIC)`. Use a `set` if the elements are hashable.
+ zerver/lib/logging_util.py:155:12: PLR1714 Consider merging multiple comparisons: `module_name in (logger_name, record.name)`. Use a `set` if the elements are hashable.
+ zerver/lib/onboarding.py:46:9: PLR1714 Consider merging multiple comparisons: `user.realm.org_type in (Realm.ORG_TYPES["education_nonprofit"]["id"], Realm.ORG_TYPES["education"]["id"])`. Use a `set` if the elements are hashable.
+ zerver/models.py:2039:13: PLR1714 Consider merging multiple comparisons: `self.role in (UserProfile.ROLE_REALM_ADMINISTRATOR, UserProfile.ROLE_REALM_OWNER)`. Use a `set` if the elements are hashable.
+ zerver/views/custom_profile_fields.py:83:8: PLR1714 Consider merging multiple comparisons: `field_type in (CustomProfileField.LONG_TEXT, CustomProfileField.USER)`. Use a `set` if the elements are hashable.
+ zerver/webhooks/clubhouse/view.py:403:12: PLR1714 Consider merging multiple comparisons: `entity in ("pull-request", "pull-request-comment")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/github/view.py:80:8: PLR1714 Consider merging multiple comparisons: `action in ("opened", "merged")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/gitlab/view.py:453:10: PLR1714 Consider merging multiple comparisons: `event in ("Job Hook", "Build Hook")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/gitlab/view.py:478:10: PLR1714 Consider merging multiple comparisons: `event in ("Note Hook Issue", "Confidential Note Hook Issue")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/pagerduty/view.py:217:9: PLR1714 Consider merging multiple comparisons: `message_type in ("incident.resolve", "incident.resolved")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/pagerduty/view.py:221:9: PLR1714 Consider merging multiple comparisons: `message_type in ("incident.resolve", "incident.resolved")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/pagerduty/view.py:224:10: PLR1714 Consider merging multiple comparisons: `message_type in ("incident.assign", "incident.reassigned")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/raygun/view.py:230:8: PLR1714 Consider merging multiple comparisons: `event_type in ("NewErrorOccurred", "ErrorReoccurred")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/raygun/view.py:289:9: PLR1714 Consider merging multiple comparisons: `event_type in ("StatusChanged", "AssignedToUser", "CommentAdded")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/sonarr/view.py:59:8: PLR1714 Consider merging multiple comparisons: `event_type not in ("Test", "Health")`. Use a `set` if the elements are hashable.
+ zerver/webhooks/wordpress/view.py:46:8: PLR1714 Consider merging multiple comparisons: `hook in ("publish_post", "publish_page")`. Use a `set` if the elements are hashable.

Rules changed: 2
Rule Changes Additions Removals
PLR1714 54 54 0
PYI036 2 2 0

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      8.4±0.01ms     4.9 MB/sec    1.01      8.4±0.01ms     4.8 MB/sec
formatter/numpy/ctypeslib.py               1.00   1901.0±4.02µs     8.8 MB/sec    1.01  1918.2±10.77µs     8.7 MB/sec
formatter/numpy/globals.py                 1.00    203.7±0.36µs    14.5 MB/sec    1.01    206.0±0.53µs    14.3 MB/sec
formatter/pydantic/types.py                1.00      4.2±0.01ms     6.0 MB/sec    1.01      4.3±0.01ms     6.0 MB/sec
linter/all-rules/large/dataset.py          1.00     14.1±0.04ms     2.9 MB/sec    1.00     14.1±0.02ms     2.9 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.5±0.00ms     4.7 MB/sec    1.00      3.5±0.01ms     4.7 MB/sec
linter/all-rules/numpy/globals.py          1.00    365.8±1.20µs     8.1 MB/sec    1.00    364.4±1.00µs     8.1 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.3±0.02ms     4.1 MB/sec    1.00      6.3±0.04ms     4.1 MB/sec
linter/default-rules/large/dataset.py      1.00      7.2±0.01ms     5.7 MB/sec    1.00      7.2±0.02ms     5.6 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1473.3±5.73µs    11.3 MB/sec    1.00   1476.4±2.90µs    11.3 MB/sec
linter/default-rules/numpy/globals.py      1.00    156.7±0.22µs    18.8 MB/sec    1.00    157.4±0.61µs    18.7 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.2±0.01ms     8.0 MB/sec    1.00      3.2±0.01ms     8.0 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      9.4±0.06ms     4.3 MB/sec    1.00      9.4±0.08ms     4.3 MB/sec
formatter/numpy/ctypeslib.py               1.00      2.1±0.03ms     7.8 MB/sec    1.02      2.2±0.03ms     7.7 MB/sec
formatter/numpy/globals.py                 1.00    239.3±4.40µs    12.3 MB/sec    1.02    243.5±7.86µs    12.1 MB/sec
formatter/pydantic/types.py                1.00      4.6±0.05ms     5.5 MB/sec    1.02      4.7±0.05ms     5.4 MB/sec
linter/all-rules/large/dataset.py          1.01     15.8±0.14ms     2.6 MB/sec    1.00     15.6±0.13ms     2.6 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      4.1±0.07ms     4.0 MB/sec    1.00      4.1±0.05ms     4.0 MB/sec
linter/all-rules/numpy/globals.py          1.00    498.2±6.05µs     5.9 MB/sec    1.01    502.3±7.88µs     5.9 MB/sec
linter/all-rules/pydantic/types.py         1.00      7.1±0.12ms     3.6 MB/sec    1.00      7.1±0.05ms     3.6 MB/sec
linter/default-rules/large/dataset.py      1.01      8.0±0.05ms     5.1 MB/sec    1.00      8.0±0.05ms     5.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1698.3±16.61µs     9.8 MB/sec    1.00  1703.5±49.55µs     9.8 MB/sec
linter/default-rules/numpy/globals.py      1.00    199.2±3.42µs    14.8 MB/sec    1.01    200.4±3.34µs    14.7 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.6±0.03ms     7.1 MB/sec    1.00      3.6±0.04ms     7.1 MB/sec

@dhruvmanila dhruvmanila force-pushed the dhruv/implicit-optional-tests branch from 8955ef9 to e47034a Compare July 12, 2023 18:17
@dhruvmanila dhruvmanila changed the title Update implicit optional tests for coverage Consider single element subscript expr for implicit optional Jul 12, 2023
@dhruvmanila dhruvmanila marked this pull request as ready for review July 12, 2023 18:19
Expr::Tuple(ast::ExprTuple { elts: elements, .. }) => elements.iter().collect(),
_ => vec![slice],
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you can avoid these allocations by just storing the slice Expr on the enums directly, and then doing this match later, when you actually need to iterate over the members.

Copy link
Member

Choose a reason for hiding this comment

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

Here's a patch of what I'm imagining:

diff --git a/crates/ruff/src/rules/ruff/typing.rs b/crates/ruff/src/rules/ruff/typing.rs
index f96ea22d8..3ad7d9c9f 100644
--- a/crates/ruff/src/rules/ruff/typing.rs
+++ b/crates/ruff/src/rules/ruff/typing.rs
@@ -1,3 +1,4 @@
+use itertools::Either::{Left, Right};
 use rustpython_parser::ast::{self, Constant, Expr, Operator};
 
 use ruff_python_ast::call_path::CallPath;
@@ -54,10 +55,10 @@ fn is_known_type(call_path: &CallPath, minor_version: u32) -> bool {
 
 /// Returns a vector of all the expressions in a slice. If the slice is not a
 /// tuple, it will be wrapped in a vector.
-fn resolve_slice_value(slice: &Expr) -> Vec<&Expr> {
+fn resolve_slice_value(slice: &Expr) -> impl Iterator<Item = &Expr> {
     match slice {
-        Expr::Tuple(ast::ExprTuple { elts: elements, .. }) => elements.iter().collect(),
-        _ => vec![slice],
+        Expr::Tuple(ast::ExprTuple { elts: elements, .. }) => Left(elements.iter()),
+        _ => Right(std::iter::once(slice)),
     }
 }
 
@@ -77,10 +78,14 @@ enum TypingTarget<'a> {
 
     /// A `typing.Union` type or `|` separated types e.g., `Union[int, str]`
     /// or `int | str`.
-    Union(Vec<&'a Expr>),
+    Union(&'a Expr),
+
+    /// A `typing.Union` type or `|` separated types e.g., `Union[int, str]`
+    /// or `int | str`.
+    Pep604Union(&'a Expr),
 
     /// A `typing.Literal` type e.g., `Literal[1, 2, 3]`.
-    Literal(Vec<&'a Expr>),
+    Literal(&'a Expr),
 
     /// A `typing.Optional` type e.g., `Optional[int]`.
     Optional(&'a Expr),
@@ -110,13 +115,13 @@ impl<'a> TypingTarget<'a> {
                 if semantic.match_typing_expr(value, "Optional") {
                     Some(TypingTarget::Optional(slice.as_ref()))
                 } else if semantic.match_typing_expr(value, "Literal") {
-                    Some(TypingTarget::Literal(resolve_slice_value(slice)))
+                    Some(TypingTarget::Literal(slice))
                 } else if semantic.match_typing_expr(value, "Union") {
-                    Some(TypingTarget::Union(resolve_slice_value(slice)))
+                    Some(TypingTarget::Union(slice))
                 } else if semantic.match_typing_expr(value, "Annotated") {
                     resolve_slice_value(slice.as_ref())
-                        .first()
-                        .map(|&expr| TypingTarget::Annotated(expr))
+                        .next()
+                        .map(|expr| TypingTarget::Annotated(expr))
                 } else {
                     semantic.resolve_call_path(value).map_or(
                         // If we can't resolve the call path, it must be defined
@@ -132,9 +137,7 @@ impl<'a> TypingTarget<'a> {
                     )
                 }
             }
-            Expr::BinOp(..) => Some(TypingTarget::Union(
-                PEP604UnionIterator::new(expr).collect(),
-            )),
+            Expr::BinOp(..) => Some(TypingTarget::Pep604Union(expr)),
             Expr::Constant(ast::ExprConstant {
                 value: Constant::None,
                 ..
@@ -179,7 +182,7 @@ impl<'a> TypingTarget<'a> {
             | TypingTarget::Object
             | TypingTarget::Unknown => true,
             TypingTarget::Known => false,
-            TypingTarget::Literal(elements) => elements.iter().any(|element| {
+            TypingTarget::Literal(element) => resolve_slice_value(element).any(|element| {
                 // Literal can only contain `None`, a literal value, other `Literal`
                 // or an enum value.
                 match TypingTarget::try_from_expr(element, semantic, locator, minor_version) {
@@ -190,12 +193,20 @@ impl<'a> TypingTarget<'a> {
                     _ => false,
                 }
             }),
-            TypingTarget::Union(elements) => elements.iter().any(|element| {
+            TypingTarget::Union(element) => resolve_slice_value(element).any(|element| {
                 TypingTarget::try_from_expr(element, semantic, locator, minor_version)
                     .map_or(true, |new_target| {
                         new_target.contains_none(semantic, locator, minor_version)
                     })
             }),
+            TypingTarget::Pep604Union(element) => {
+                PEP604UnionIterator::new(element).any(|element| {
+                    TypingTarget::try_from_expr(element, semantic, locator, minor_version)
+                        .map_or(true, |new_target| {
+                            new_target.contains_none(semantic, locator, minor_version)
+                        })
+                })
+            }
             TypingTarget::Annotated(element) => {
                 TypingTarget::try_from_expr(element, semantic, locator, minor_version)
                     .map_or(true, |new_target| {
@@ -226,12 +237,20 @@ impl<'a> TypingTarget<'a> {
             | TypingTarget::Object
             | TypingTarget::Known
             | TypingTarget::Unknown => false,
-            TypingTarget::Union(elements) => elements.iter().any(|element| {
+            TypingTarget::Union(element) => resolve_slice_value(element).any(|element| {
                 TypingTarget::try_from_expr(element, semantic, locator, minor_version)
                     .map_or(true, |new_target| {
                         new_target.contains_any(semantic, locator, minor_version)
                     })
             }),
+            TypingTarget::Pep604Union(element) => {
+                PEP604UnionIterator::new(element).any(|element| {
+                    TypingTarget::try_from_expr(element, semantic, locator, minor_version)
+                        .map_or(true, |new_target| {
+                            new_target.contains_any(semantic, locator, minor_version)
+                        })
+                })
+            }
             TypingTarget::Annotated(element) | TypingTarget::Optional(element) => {
                 TypingTarget::try_from_expr(element, semantic, locator, minor_version)
                     .map_or(true, |new_target| {

Copy link
Member

Choose a reason for hiding this comment

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

This lets you avoid any allocations 😍

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh wow! That's neat :)

We could even go further and merge Union and | separated unions together in the slice resolver but then that would need to an enum as itertools::Either is only for 2 sum types. It would be kinda similar to this implementation except that the duplication of PEP604UnionIterator call will be avoided at the expense of having an additional type.

I think this separation is ok for now.

@dhruvmanila dhruvmanila force-pushed the dhruv/typing-target-contains-any branch from 63894df to 01866f9 Compare July 13, 2023 06:42
@dhruvmanila dhruvmanila force-pushed the dhruv/implicit-optional-tests branch from 87f7fc2 to bd27d7a Compare July 13, 2023 06:42
@@ -19,7 +19,6 @@ ignore = [
"T", # flake8-print
"FBT", # flake8-boolean-trap
"PERF", # perflint
"ANN401",
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactoring the implementation as described here introduced a subtle bug which this PR is solving but the bug exists in the parent PR. Ideally, the stack should've been in the reverse order such that this PR is based on the main branch but I didn't realize this until quite late. Then, the rebase required a lot of effort which didn't seem worthwhile.

So, the simple solution is to disable the check on the parent PR and enable it back again in this PR. Sorry for the confusion!

Base automatically changed from dhruv/typing-target-contains-any to main July 13, 2023 12:49
@dhruvmanila dhruvmanila enabled auto-merge (squash) July 13, 2023 12:57
@dhruvmanila dhruvmanila added the rule Implementing or modifying a lint rule label Jul 13, 2023
@dhruvmanila dhruvmanila merged commit cf48ad7 into main Jul 13, 2023
@dhruvmanila dhruvmanila deleted the dhruv/implicit-optional-tests branch July 13, 2023 13:10
konstin pushed a commit that referenced this pull request Jul 19, 2023
## Summary

Consider single element subscript expr for implicit optional.

On `main`, the cases where there is only a single element in the
subscript
list was giving false positives such as for the following:

```python
typing.Union[None]
typing.Literal[None]
```

## Test Plan

`cargo test`

---------

Co-authored-by: Charlie Marsh <[email protected]>
jankatins referenced this pull request in jankatins/pr-workflow-example Jul 22, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `0.0.278`
-> `0.0.280` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/ruff/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/ruff/0.0.278/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.0.278/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.280`](https://togithub.com/astral-sh/ruff/compare/v0.0.279...v0.0.280)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.279...v0.0.280)

###
[`v0.0.279`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.279)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.278...v0.0.279)

<!-- Release notes generated using configuration in .github/release.yml
at v0.0.279 -->

#### What's Changed

##### Rules

- \[`flake8-pyi`] Implement flake8-pyi's PYI026 by
[@&#8203;LaBatata101](https://togithub.com/LaBatata101) in
[https://github.com/astral-sh/ruff/pull/5844](https://togithub.com/astral-sh/ruff/pull/5844)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI017` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[https://github.com/astral-sh/ruff/pull/5895](https://togithub.com/astral-sh/ruff/pull/5895)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI036` by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5668](https://togithub.com/astral-sh/ruff/pull/5668)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI041` by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5722](https://togithub.com/astral-sh/ruff/pull/5722)
- \[`flake8-use-pathlib`] Implement `os-path-getsize` and
`os-path-get(a|m|c)-time` (`PTH202-205`) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5835](https://togithub.com/astral-sh/ruff/pull/5835)
- \[`flake8-use-pathlib`] Implement `path-constructor-default-argument`
(`PTH201`) by [@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5833](https://togithub.com/astral-sh/ruff/pull/5833)
- \[`pandas-vet`] Implement constant series rule (`PD101`) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5802](https://togithub.com/astral-sh/ruff/pull/5802)
- \[`pylint`] Implement Pylint's `consider-using-in` (`PLR1714`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5193](https://togithub.com/astral-sh/ruff/pull/5193)

##### Rule changes

- \[`flake8-annotations`] Check for `Any` in other types for `ANN401` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5601](https://togithub.com/astral-sh/ruff/pull/5601)
- \[`flake8-bugbear`] Add autofix for B004 by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5788](https://togithub.com/astral-sh/ruff/pull/5788)
- \[`flake8-bugbear`] Remove `B904`'s lowercase exemption by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5751](https://togithub.com/astral-sh/ruff/pull/5751)
- \[`flake8-use-pathlib`] extend PTH118 with `os.sep` by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5935](https://togithub.com/astral-sh/ruff/pull/5935)
- \[`pyupgrade`] Expand scope of `quoted-annotation` rule (`UP037`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5766](https://togithub.com/astral-sh/ruff/pull/5766)
- \[`pyupgrade`] Extend PEP 604 rewrites to support some quoted
annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5725](https://togithub.com/astral-sh/ruff/pull/5725)
- \[`ruff`] Expand `RUF015` to include all expression types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5767](https://togithub.com/astral-sh/ruff/pull/5767)

##### Bug Fixes

- Consider single element subscript expr for implicit optional by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5717](https://togithub.com/astral-sh/ruff/pull/5717)
- Ignore `Enum`-and-`str` subclasses for slots enforcement by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5749](https://togithub.com/astral-sh/ruff/pull/5749)
- Avoid removing raw strings in comparison fixes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5755](https://togithub.com/astral-sh/ruff/pull/5755)
- Fix nested calls to `sorted` with differing arguments by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5761](https://togithub.com/astral-sh/ruff/pull/5761)
- Use unused variable detection to power `incorrect-dict-iterator` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5763](https://togithub.com/astral-sh/ruff/pull/5763)
- Include alias when formatting import-from structs by
[@&#8203;guillaumeLepape](https://togithub.com/guillaumeLepape) in
[https://github.com/astral-sh/ruff/pull/5786](https://togithub.com/astral-sh/ruff/pull/5786)
- Make `lint_only` aware of the source kind by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5876](https://togithub.com/astral-sh/ruff/pull/5876)
- Restore `redefined-while-unused` violations in classes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5926](https://togithub.com/astral-sh/ruff/pull/5926)
- Flatten nested tuples when fixing UP007 violations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5724](https://togithub.com/astral-sh/ruff/pull/5724)
- Ignore Jupyter Notebooks for `--add-noqa` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5727](https://togithub.com/astral-sh/ruff/pull/5727)
- Avoid checking `EXE001` and `EXE002` on WSL by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5735](https://togithub.com/astral-sh/ruff/pull/5735)
- Properly group assignment targets by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[https://github.com/astral-sh/ruff/pull/5728](https://togithub.com/astral-sh/ruff/pull/5728)
- Avoid stack overflow for non-BitOr binary types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5743](https://togithub.com/astral-sh/ruff/pull/5743)
- Move function visit out of `Expr::Call` branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5772](https://togithub.com/astral-sh/ruff/pull/5772)
- \[B006] Add bytes to immutable types by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5776](https://togithub.com/astral-sh/ruff/pull/5776)
- Format `SetComp` by [@&#8203;lkh42t](https://togithub.com/lkh42t) in
[https://github.com/astral-sh/ruff/pull/5774](https://togithub.com/astral-sh/ruff/pull/5774)
- Gate `runtime-import-in-type-checking-block` (`TCH004`) behind enabled
flag by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5789](https://togithub.com/astral-sh/ruff/pull/5789)
- perf: only compute start offset for overlong lines by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5811](https://togithub.com/astral-sh/ruff/pull/5811)
- Change `pandas-use-of-dot-read-table` rule to emit only when
`read_table` is used on CSV data by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5807](https://togithub.com/astral-sh/ruff/pull/5807)
- Do not fix `NamedTuple` calls containing both a list of fields and
keywords by [@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5799](https://togithub.com/astral-sh/ruff/pull/5799)
- Ignore directories when collecting files to lint by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5775](https://togithub.com/astral-sh/ruff/pull/5775)
- Add filename to `noqa` warnings by
[@&#8203;sobolevn](https://togithub.com/sobolevn) in
[https://github.com/astral-sh/ruff/pull/5856](https://togithub.com/astral-sh/ruff/pull/5856)
- Handle io errors gracefully by
[@&#8203;konstin](https://togithub.com/konstin) in
[https://github.com/astral-sh/ruff/pull/5611](https://togithub.com/astral-sh/ruff/pull/5611)
- Allow `respect_gitignore` when not in a git repo by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5937](https://togithub.com/astral-sh/ruff/pull/5937)

#### New Contributors

- [@&#8203;eggplants](https://togithub.com/eggplants) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5741](https://togithub.com/astral-sh/ruff/pull/5741)
- [@&#8203;guillaumeLepape](https://togithub.com/guillaumeLepape) made
their first contribution in
[https://github.com/astral-sh/ruff/pull/5786](https://togithub.com/astral-sh/ruff/pull/5786)
- [@&#8203;odiseo0](https://togithub.com/odiseo0) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5888](https://togithub.com/astral-sh/ruff/pull/5888)
- [@&#8203;DavidCain](https://togithub.com/DavidCain) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5889](https://togithub.com/astral-sh/ruff/pull/5889)
- [@&#8203;LaBatata101](https://togithub.com/LaBatata101) made their
first contribution in
[https://github.com/astral-sh/ruff/pull/5844](https://togithub.com/astral-sh/ruff/pull/5844)

**Full Changelog**:
astral-sh/ruff@v0.0.278...v0.0.279

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/jankatins/pr-workflow-example).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
renovate bot referenced this pull request in allenporter/pyrainbird Jul 23, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `==0.0.278`
-> `==0.0.280` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/ruff/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/ruff/0.0.278/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.0.278/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.280`](https://togithub.com/astral-sh/ruff/compare/v0.0.279...v0.0.280)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.279...v0.0.280)

###
[`v0.0.279`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.279)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.278...v0.0.279)

<!-- Release notes generated using configuration in .github/release.yml
at v0.0.279 -->

#### What's Changed

##### Rules

- \[`flake8-pyi`] Implement flake8-pyi's PYI026 by
[@&#8203;LaBatata101](https://togithub.com/LaBatata101) in
[https://github.com/astral-sh/ruff/pull/5844](https://togithub.com/astral-sh/ruff/pull/5844)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI017` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[https://github.com/astral-sh/ruff/pull/5895](https://togithub.com/astral-sh/ruff/pull/5895)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI036` by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5668](https://togithub.com/astral-sh/ruff/pull/5668)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI041` by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5722](https://togithub.com/astral-sh/ruff/pull/5722)
- \[`flake8-use-pathlib`] Implement `os-path-getsize` and
`os-path-get(a|m|c)-time` (`PTH202-205`) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5835](https://togithub.com/astral-sh/ruff/pull/5835)
- \[`flake8-use-pathlib`] Implement `path-constructor-default-argument`
(`PTH201`) by [@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5833](https://togithub.com/astral-sh/ruff/pull/5833)
- \[`pandas-vet`] Implement constant series rule (`PD101`) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5802](https://togithub.com/astral-sh/ruff/pull/5802)
- \[`pylint`] Implement Pylint's `consider-using-in` (`PLR1714`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5193](https://togithub.com/astral-sh/ruff/pull/5193)

##### Rule changes

- \[`flake8-annotations`] Check for `Any` in other types for `ANN401` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5601](https://togithub.com/astral-sh/ruff/pull/5601)
- \[`flake8-bugbear`] Add autofix for B004 by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5788](https://togithub.com/astral-sh/ruff/pull/5788)
- \[`flake8-bugbear`] Remove `B904`'s lowercase exemption by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5751](https://togithub.com/astral-sh/ruff/pull/5751)
- \[`flake8-use-pathlib`] extend PTH118 with `os.sep` by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5935](https://togithub.com/astral-sh/ruff/pull/5935)
- \[`pyupgrade`] Expand scope of `quoted-annotation` rule (`UP037`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5766](https://togithub.com/astral-sh/ruff/pull/5766)
- \[`pyupgrade`] Extend PEP 604 rewrites to support some quoted
annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5725](https://togithub.com/astral-sh/ruff/pull/5725)
- \[`ruff`] Expand `RUF015` to include all expression types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5767](https://togithub.com/astral-sh/ruff/pull/5767)

##### Bug Fixes

- Consider single element subscript expr for implicit optional by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5717](https://togithub.com/astral-sh/ruff/pull/5717)
- Ignore `Enum`-and-`str` subclasses for slots enforcement by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5749](https://togithub.com/astral-sh/ruff/pull/5749)
- Avoid removing raw strings in comparison fixes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5755](https://togithub.com/astral-sh/ruff/pull/5755)
- Fix nested calls to `sorted` with differing arguments by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5761](https://togithub.com/astral-sh/ruff/pull/5761)
- Use unused variable detection to power `incorrect-dict-iterator` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5763](https://togithub.com/astral-sh/ruff/pull/5763)
- Include alias when formatting import-from structs by
[@&#8203;guillaumeLepape](https://togithub.com/guillaumeLepape) in
[https://github.com/astral-sh/ruff/pull/5786](https://togithub.com/astral-sh/ruff/pull/5786)
- Make `lint_only` aware of the source kind by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5876](https://togithub.com/astral-sh/ruff/pull/5876)
- Restore `redefined-while-unused` violations in classes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5926](https://togithub.com/astral-sh/ruff/pull/5926)
- Flatten nested tuples when fixing UP007 violations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5724](https://togithub.com/astral-sh/ruff/pull/5724)
- Ignore Jupyter Notebooks for `--add-noqa` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5727](https://togithub.com/astral-sh/ruff/pull/5727)
- Avoid checking `EXE001` and `EXE002` on WSL by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5735](https://togithub.com/astral-sh/ruff/pull/5735)
- Properly group assignment targets by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[https://github.com/astral-sh/ruff/pull/5728](https://togithub.com/astral-sh/ruff/pull/5728)
- Avoid stack overflow for non-BitOr binary types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5743](https://togithub.com/astral-sh/ruff/pull/5743)
- Move function visit out of `Expr::Call` branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5772](https://togithub.com/astral-sh/ruff/pull/5772)
- \[B006] Add bytes to immutable types by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5776](https://togithub.com/astral-sh/ruff/pull/5776)
- Format `SetComp` by [@&#8203;lkh42t](https://togithub.com/lkh42t) in
[https://github.com/astral-sh/ruff/pull/5774](https://togithub.com/astral-sh/ruff/pull/5774)
- Gate `runtime-import-in-type-checking-block` (`TCH004`) behind enabled
flag by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5789](https://togithub.com/astral-sh/ruff/pull/5789)
- perf: only compute start offset for overlong lines by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5811](https://togithub.com/astral-sh/ruff/pull/5811)
- Change `pandas-use-of-dot-read-table` rule to emit only when
`read_table` is used on CSV data by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5807](https://togithub.com/astral-sh/ruff/pull/5807)
- Do not fix `NamedTuple` calls containing both a list of fields and
keywords by [@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5799](https://togithub.com/astral-sh/ruff/pull/5799)
- Ignore directories when collecting files to lint by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5775](https://togithub.com/astral-sh/ruff/pull/5775)
- Add filename to `noqa` warnings by
[@&#8203;sobolevn](https://togithub.com/sobolevn) in
[https://github.com/astral-sh/ruff/pull/5856](https://togithub.com/astral-sh/ruff/pull/5856)
- Handle io errors gracefully by
[@&#8203;konstin](https://togithub.com/konstin) in
[https://github.com/astral-sh/ruff/pull/5611](https://togithub.com/astral-sh/ruff/pull/5611)
- Allow `respect_gitignore` when not in a git repo by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5937](https://togithub.com/astral-sh/ruff/pull/5937)

#### New Contributors

- [@&#8203;eggplants](https://togithub.com/eggplants) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5741](https://togithub.com/astral-sh/ruff/pull/5741)
- [@&#8203;guillaumeLepape](https://togithub.com/guillaumeLepape) made
their first contribution in
[https://github.com/astral-sh/ruff/pull/5786](https://togithub.com/astral-sh/ruff/pull/5786)
- [@&#8203;odiseo0](https://togithub.com/odiseo0) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5888](https://togithub.com/astral-sh/ruff/pull/5888)
- [@&#8203;DavidCain](https://togithub.com/DavidCain) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5889](https://togithub.com/astral-sh/ruff/pull/5889)
- [@&#8203;LaBatata101](https://togithub.com/LaBatata101) made their
first contribution in
[https://github.com/astral-sh/ruff/pull/5844](https://togithub.com/astral-sh/ruff/pull/5844)

**Full Changelog**:
astral-sh/ruff@v0.0.278...v0.0.279

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/allenporter/pyrainbird).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot referenced this pull request in allenporter/flux-local Jul 24, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `==0.0.278`
-> `==0.0.280` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/ruff/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/ruff/0.0.278/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.0.278/0.0.280?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.280`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.280)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.279...v0.0.280)

<!-- Release notes generated using configuration in .github/release.yml
at v0.0.280 -->

#### What's Changed

##### Bug Fixes

- Avoid collapsing `elif` and `else` branches during import sorting by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5964](https://togithub.com/astral-sh/ruff/pull/5964)

**Full Changelog**:
astral-sh/ruff@v0.0.279...v0.0.280

###
[`v0.0.279`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.279)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.278...v0.0.279)

<!-- Release notes generated using configuration in .github/release.yml
at v0.0.279 -->

#### What's Changed

##### Rules

- \[`flake8-pyi`] Implement flake8-pyi's PYI026 by
[@&#8203;LaBatata101](https://togithub.com/LaBatata101) in
[https://github.com/astral-sh/ruff/pull/5844](https://togithub.com/astral-sh/ruff/pull/5844)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI017` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[https://github.com/astral-sh/ruff/pull/5895](https://togithub.com/astral-sh/ruff/pull/5895)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI036` by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5668](https://togithub.com/astral-sh/ruff/pull/5668)
- \[`flake8-pyi`] Implement flake8-pyi's `PYI041` by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5722](https://togithub.com/astral-sh/ruff/pull/5722)
- \[`flake8-use-pathlib`] Implement `os-path-getsize` and
`os-path-get(a|m|c)-time` (`PTH202-205`) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5835](https://togithub.com/astral-sh/ruff/pull/5835)
- \[`flake8-use-pathlib`] Implement `path-constructor-default-argument`
(`PTH201`) by [@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5833](https://togithub.com/astral-sh/ruff/pull/5833)
- \[`pandas-vet`] Implement constant series rule (`PD101`) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5802](https://togithub.com/astral-sh/ruff/pull/5802)
- \[`pylint`] Implement Pylint's `consider-using-in` (`PLR1714`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5193](https://togithub.com/astral-sh/ruff/pull/5193)

##### Rule changes

- \[`flake8-annotations`] Check for `Any` in other types for `ANN401` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5601](https://togithub.com/astral-sh/ruff/pull/5601)
- \[`flake8-bugbear`] Add autofix for B004 by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5788](https://togithub.com/astral-sh/ruff/pull/5788)
- \[`flake8-bugbear`] Remove `B904`'s lowercase exemption by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5751](https://togithub.com/astral-sh/ruff/pull/5751)
- \[`flake8-use-pathlib`] extend PTH118 with `os.sep` by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5935](https://togithub.com/astral-sh/ruff/pull/5935)
- \[`pyupgrade`] Expand scope of `quoted-annotation` rule (`UP037`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5766](https://togithub.com/astral-sh/ruff/pull/5766)
- \[`pyupgrade`] Extend PEP 604 rewrites to support some quoted
annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5725](https://togithub.com/astral-sh/ruff/pull/5725)
- \[`ruff`] Expand `RUF015` to include all expression types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5767](https://togithub.com/astral-sh/ruff/pull/5767)

##### Bug Fixes

- Consider single element subscript expr for implicit optional by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5717](https://togithub.com/astral-sh/ruff/pull/5717)
- Ignore `Enum`-and-`str` subclasses for slots enforcement by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5749](https://togithub.com/astral-sh/ruff/pull/5749)
- Avoid removing raw strings in comparison fixes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5755](https://togithub.com/astral-sh/ruff/pull/5755)
- Fix nested calls to `sorted` with differing arguments by
[@&#8203;density](https://togithub.com/density) in
[https://github.com/astral-sh/ruff/pull/5761](https://togithub.com/astral-sh/ruff/pull/5761)
- Use unused variable detection to power `incorrect-dict-iterator` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5763](https://togithub.com/astral-sh/ruff/pull/5763)
- Include alias when formatting import-from structs by
[@&#8203;guillaumeLepape](https://togithub.com/guillaumeLepape) in
[https://github.com/astral-sh/ruff/pull/5786](https://togithub.com/astral-sh/ruff/pull/5786)
- Make `lint_only` aware of the source kind by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5876](https://togithub.com/astral-sh/ruff/pull/5876)
- Restore `redefined-while-unused` violations in classes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5926](https://togithub.com/astral-sh/ruff/pull/5926)
- Flatten nested tuples when fixing UP007 violations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5724](https://togithub.com/astral-sh/ruff/pull/5724)
- Ignore Jupyter Notebooks for `--add-noqa` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5727](https://togithub.com/astral-sh/ruff/pull/5727)
- Avoid checking `EXE001` and `EXE002` on WSL by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5735](https://togithub.com/astral-sh/ruff/pull/5735)
- Properly group assignment targets by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[https://github.com/astral-sh/ruff/pull/5728](https://togithub.com/astral-sh/ruff/pull/5728)
- Avoid stack overflow for non-BitOr binary types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5743](https://togithub.com/astral-sh/ruff/pull/5743)
- Move function visit out of `Expr::Call` branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5772](https://togithub.com/astral-sh/ruff/pull/5772)
- \[B006] Add bytes to immutable types by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5776](https://togithub.com/astral-sh/ruff/pull/5776)
- Format `SetComp` by [@&#8203;lkh42t](https://togithub.com/lkh42t) in
[https://github.com/astral-sh/ruff/pull/5774](https://togithub.com/astral-sh/ruff/pull/5774)
- Gate `runtime-import-in-type-checking-block` (`TCH004`) behind enabled
flag by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/astral-sh/ruff/pull/5789](https://togithub.com/astral-sh/ruff/pull/5789)
- perf: only compute start offset for overlong lines by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/astral-sh/ruff/pull/5811](https://togithub.com/astral-sh/ruff/pull/5811)
- Change `pandas-use-of-dot-read-table` rule to emit only when
`read_table` is used on CSV data by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[https://github.com/astral-sh/ruff/pull/5807](https://togithub.com/astral-sh/ruff/pull/5807)
- Do not fix `NamedTuple` calls containing both a list of fields and
keywords by [@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5799](https://togithub.com/astral-sh/ruff/pull/5799)
- Ignore directories when collecting files to lint by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/astral-sh/ruff/pull/5775](https://togithub.com/astral-sh/ruff/pull/5775)
- Add filename to `noqa` warnings by
[@&#8203;sobolevn](https://togithub.com/sobolevn) in
[https://github.com/astral-sh/ruff/pull/5856](https://togithub.com/astral-sh/ruff/pull/5856)
- Handle io errors gracefully by
[@&#8203;konstin](https://togithub.com/konstin) in
[https://github.com/astral-sh/ruff/pull/5611](https://togithub.com/astral-sh/ruff/pull/5611)
- Allow `respect_gitignore` when not in a git repo by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[https://github.com/astral-sh/ruff/pull/5937](https://togithub.com/astral-sh/ruff/pull/5937)

#### New Contributors

- [@&#8203;eggplants](https://togithub.com/eggplants) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5741](https://togithub.com/astral-sh/ruff/pull/5741)
- [@&#8203;guillaumeLepape](https://togithub.com/guillaumeLepape) made
their first contribution in
[https://github.com/astral-sh/ruff/pull/5786](https://togithub.com/astral-sh/ruff/pull/5786)
- [@&#8203;odiseo0](https://togithub.com/odiseo0) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5888](https://togithub.com/astral-sh/ruff/pull/5888)
- [@&#8203;DavidCain](https://togithub.com/DavidCain) made their first
contribution in
[https://github.com/astral-sh/ruff/pull/5889](https://togithub.com/astral-sh/ruff/pull/5889)
- [@&#8203;LaBatata101](https://togithub.com/LaBatata101) made their
first contribution in
[https://github.com/astral-sh/ruff/pull/5844](https://togithub.com/astral-sh/ruff/pull/5844)

**Full Changelog**:
astral-sh/ruff@v0.0.278...v0.0.279

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants