Skip to content

Commit a18a7ce

Browse files
committed
Merge remote-tracking branch 'origin/main' into reachability-ambiguous-not-definitely-bound
2 parents ee1cb2c + 18eaa65 commit a18a7ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3054
-904
lines changed

crates/ruff_linter/resources/test/fixtures/airflow/AIR311_names.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,36 @@
7474

7575
# airflow.utils.dag_parsing_context
7676
get_parsing_context()
77+
78+
from airflow.decorators.base import (
79+
DecoratedMappedOperator,
80+
DecoratedOperator,
81+
TaskDecorator,
82+
get_unique_task_id,
83+
task_decorator_factory,
84+
)
85+
86+
# airflow.decorators.base
87+
DecoratedMappedOperator()
88+
DecoratedOperator()
89+
TaskDecorator()
90+
get_unique_task_id()
91+
task_decorator_factory()
92+
93+
94+
from airflow.models import Param
95+
96+
# airflow.models
97+
Param()
98+
99+
100+
from airflow.sensors.base import (
101+
BaseSensorOperator,
102+
PokeReturnValue,
103+
poke_mode_only,
104+
)
105+
106+
# airflow.sensors.base
107+
BaseSensorOperator()
108+
PokeReturnValue()
109+
poke_mode_only()

crates/ruff_linter/resources/test/fixtures/airflow/AIR312.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from airflow.operators.latest_only import LatestOnlyOperator
1010
from airflow.operators.trigger_dagrun import TriggerDagRunOperator
1111
from airflow.operators.weekday import BranchDayOfWeekOperator
12-
from airflow.sensors.date_time import DateTimeSensor
1312

1413
FSHook()
1514
PackageIndexHook()
@@ -22,24 +21,30 @@
2221

2322
LatestOnlyOperator()
2423
BranchDayOfWeekOperator()
25-
DateTimeSensor()
2624

2725
from airflow.operators.python import (
2826
BranchPythonOperator,
2927
PythonOperator,
3028
PythonVirtualenvOperator,
3129
ShortCircuitOperator,
3230
)
31+
from airflow.sensors.bash import BashSensor
32+
from airflow.sensors.date_time import DateTimeSensor
33+
34+
BranchPythonOperator()
35+
PythonOperator()
36+
PythonVirtualenvOperator()
37+
ShortCircuitOperator()
38+
39+
BashSensor()
40+
DateTimeSensor()
3341
from airflow.sensors.date_time import DateTimeSensorAsync
3442
from airflow.sensors.external_task import (
3543
ExternalTaskMarker,
3644
ExternalTaskSensor,
3745
)
38-
from airflow.sensors.time_sensor import (
39-
TimeSensor,
40-
TimeSensorAsync,
41-
)
4246
from airflow.sensors.filesystem import FileSensor
47+
from airflow.sensors.python import PythonSensor
4348

4449
BranchPythonOperator()
4550
PythonOperator()
@@ -49,6 +54,13 @@
4954
ExternalTaskMarker()
5055
ExternalTaskSensor()
5156
FileSensor()
57+
PythonSensor()
58+
59+
from airflow.sensors.time_sensor import (
60+
TimeSensor,
61+
TimeSensorAsync,
62+
)
63+
5264
TimeSensor()
5365
TimeSensorAsync()
5466

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from typing import Optional
2+
3+
import httpx
4+
5+
6+
def foo():
7+
client = httpx.Client()
8+
client.close() # Ok
9+
client.delete() # Ok
10+
client.get() # Ok
11+
client.head() # Ok
12+
client.options() # Ok
13+
client.patch() # Ok
14+
client.post() # Ok
15+
client.put() # Ok
16+
client.request() # Ok
17+
client.send() # Ok
18+
client.stream() # Ok
19+
20+
client.anything() # Ok
21+
client.build_request() # Ok
22+
client.is_closed # Ok
23+
24+
25+
async def foo():
26+
client = httpx.Client()
27+
client.close() # ASYNC212
28+
client.delete() # ASYNC212
29+
client.get() # ASYNC212
30+
client.head() # ASYNC212
31+
client.options() # ASYNC212
32+
client.patch() # ASYNC212
33+
client.post() # ASYNC212
34+
client.put() # ASYNC212
35+
client.request() # ASYNC212
36+
client.send() # ASYNC212
37+
client.stream() # ASYNC212
38+
39+
client.anything() # Ok
40+
client.build_request() # Ok
41+
client.is_closed # Ok
42+
43+
44+
async def foo(client: httpx.Client):
45+
client.request() # ASYNC212
46+
client.anything() # Ok
47+
48+
49+
async def foo(client: httpx.Client | None):
50+
client.request() # ASYNC212
51+
client.anything() # Ok
52+
53+
54+
async def foo(client: Optional[httpx.Client]):
55+
client.request() # ASYNC212
56+
client.anything() # Ok
57+
58+
59+
async def foo():
60+
client: httpx.Client = ...
61+
client.request() # ASYNC212
62+
client.anything() # Ok
63+
64+
65+
global_client = httpx.Client()
66+
67+
68+
async def foo():
69+
global_client.request() # ASYNC212
70+
global_client.anything() # Ok
71+
72+
73+
async def foo():
74+
async with httpx.AsyncClient() as client:
75+
await client.get() # Ok

crates/ruff_linter/resources/test/fixtures/ruff/RUF033.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,19 @@ def __post_init__(
124124
...
125125

126126
return Foo
127+
128+
129+
@dataclass
130+
class C:
131+
def __post_init__(self, x: tuple[int, ...] = (
132+
1,
133+
2,
134+
)) -> None:
135+
self.x = x
136+
137+
138+
@dataclass
139+
class D:
140+
def __post_init__(self, x: int = """
141+
""") -> None:
142+
self.x = x

crates/ruff_linter/src/checkers/ast/analyze/expression.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,9 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
660660
if checker.is_rule_enabled(Rule::BlockingHttpCallInAsyncFunction) {
661661
flake8_async::rules::blocking_http_call(checker, call);
662662
}
663+
if checker.is_rule_enabled(Rule::BlockingHttpCallHttpxInAsyncFunction) {
664+
flake8_async::rules::blocking_http_call_httpx(checker, call);
665+
}
663666
if checker.is_rule_enabled(Rule::BlockingOpenCallInAsyncFunction) {
664667
flake8_async::rules::blocking_open_call(checker, call);
665668
}

crates/ruff_linter/src/codes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
336336
(Flake8Async, "115") => (RuleGroup::Stable, rules::flake8_async::rules::AsyncZeroSleep),
337337
(Flake8Async, "116") => (RuleGroup::Preview, rules::flake8_async::rules::LongSleepNotForever),
338338
(Flake8Async, "210") => (RuleGroup::Stable, rules::flake8_async::rules::BlockingHttpCallInAsyncFunction),
339+
(Flake8Async, "212") => (RuleGroup::Preview, rules::flake8_async::rules::BlockingHttpCallHttpxInAsyncFunction),
339340
(Flake8Async, "220") => (RuleGroup::Stable, rules::flake8_async::rules::CreateSubprocessInAsyncFunction),
340341
(Flake8Async, "221") => (RuleGroup::Stable, rules::flake8_async::rules::RunProcessInAsyncFunction),
341342
(Flake8Async, "222") => (RuleGroup::Stable, rules::flake8_async::rules::WaitForProcessInAsyncFunction),

crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ fn check_names_moved_to_provider(checker: &Checker, expr: &Expr, ranged: TextRan
215215
version: "0.0.1",
216216
}
217217
}
218+
["airflow", "sensors", "bash", "BashSensor"] => ProviderReplacement::AutoImport {
219+
module: "airflow.providers.standard.sensor.bash",
220+
name: "BashSensor",
221+
provider: "standard",
222+
version: "0.0.1",
223+
},
218224
[
219225
"airflow",
220226
"sensors",
@@ -243,6 +249,12 @@ fn check_names_moved_to_provider(checker: &Checker, expr: &Expr, ranged: TextRan
243249
provider: "standard",
244250
version: "0.0.2",
245251
},
252+
["airflow", "sensors", "python", "PythonSensor"] => ProviderReplacement::AutoImport {
253+
module: "airflow.providers.standard.sensors.python",
254+
name: "PythonSensor",
255+
provider: "standard",
256+
version: "0.0.1",
257+
},
246258
[
247259
"airflow",
248260
"sensors",

crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
227227
module: "airflow.sdk",
228228
name: (*rest).to_string(),
229229
},
230+
[
231+
"airflow",
232+
"decorators",
233+
"base",
234+
rest @ ("DecoratedMappedOperator"
235+
| "DecoratedOperator"
236+
| "TaskDecorator"
237+
| "get_unique_task_id"
238+
| "task_decorator_factory"),
239+
] => Replacement::SourceModuleMoved {
240+
module: "airflow.sdk.bases.decorator",
241+
name: (*rest).to_string(),
242+
},
230243

231244
// airflow.io
232245
["airflow", "io", "path", "ObjectStoragePath"] => Replacement::SourceModuleMoved {
@@ -245,6 +258,10 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
245258
name: (*rest).to_string(),
246259
}
247260
}
261+
["airflow", "models", "Param"] => Replacement::AutoImport {
262+
module: "airflow.sdk.definitions.param",
263+
name: "Param",
264+
},
248265

249266
// airflow.models.baseoperator
250267
[
@@ -260,16 +277,30 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
260277
module: "airflow.sdk",
261278
name: "BaseOperatorLink",
262279
},
280+
263281
// airflow.model..DAG
264282
["airflow", "models", .., "DAG"] => Replacement::SourceModuleMoved {
265283
module: "airflow.sdk",
266284
name: "DAG".to_string(),
267285
},
286+
287+
// airflow.sensors.base
288+
[
289+
"airflow",
290+
"sensors",
291+
"base",
292+
rest @ ("BaseSensorOperator" | "PokeReturnValue" | "poke_mode_only"),
293+
] => Replacement::SourceModuleMoved {
294+
module: "airflow.sdk",
295+
name: (*rest).to_string(),
296+
},
297+
268298
// airflow.timetables
269299
["airflow", "timetables", "datasets", "DatasetOrTimeSchedule"] => Replacement::AutoImport {
270300
module: "airflow.timetables.assets",
271301
name: "AssetOrTimeSchedule",
272302
},
303+
273304
// airflow.utils
274305
[
275306
"airflow",

0 commit comments

Comments
 (0)