@@ -58,8 +58,12 @@ impl Violation for Airflow3Removal {
5858 } = self ;
5959 match replacement {
6060 Replacement :: None
61- | Replacement :: AttrName ( _)
6261 | Replacement :: Message ( _)
62+ | Replacement :: AttrName ( _)
63+ | Replacement :: AttrNameWithMessage {
64+ attr_name : _,
65+ message : _,
66+ }
6367 | Replacement :: Rename { module : _, name : _ }
6468 | Replacement :: SourceModuleMoved { module : _, name : _ } => {
6569 format ! ( "`{deprecated}` is removed in Airflow 3.0" )
@@ -71,8 +75,11 @@ impl Violation for Airflow3Removal {
7175 let Airflow3Removal { replacement, .. } = self ;
7276 match replacement {
7377 Replacement :: None => None ,
74- Replacement :: AttrName ( name) => Some ( format ! ( "Use `{name}` instead" ) ) ,
7578 Replacement :: Message ( message) => Some ( ( * message) . to_string ( ) ) ,
79+ Replacement :: AttrName ( name) => Some ( format ! ( "Use `{name}` instead" ) ) ,
80+ Replacement :: AttrNameWithMessage { attr_name, message } => {
81+ Some ( format ! ( "Use `{attr_name}` instead; {message}" ) )
82+ }
7683 Replacement :: Rename { module, name } => {
7784 Some ( format ! ( "Use `{name}` from `{module}` instead." ) )
7885 }
@@ -98,7 +105,7 @@ pub(crate) fn airflow_3_removal_expr(checker: &Checker, expr: &Expr) {
98105 if let Some ( qualified_name) = checker. semantic ( ) . resolve_qualified_name ( func) {
99106 check_call_arguments ( checker, & qualified_name, arguments) ;
100107 }
101- check_method ( checker, call_expr) ;
108+ check_method ( checker, call_expr, arguments ) ;
102109 check_context_key_usage_in_call ( checker, call_expr) ;
103110 }
104111 Expr :: Attribute ( attribute_expr @ ExprAttribute { range, .. } ) => {
@@ -467,7 +474,7 @@ fn is_kwarg_parameter(semantic: &SemanticModel, name: &ExprName) -> bool {
467474/// manager = DatasetManager()
468475/// manager.register_datsaet_change()
469476/// ```
470- fn check_method ( checker : & Checker , call_expr : & ExprCall ) {
477+ fn check_method ( checker : & Checker , call_expr : & ExprCall , arguments : & Arguments ) {
471478 let Expr :: Attribute ( ExprAttribute { attr, value, .. } ) = & * call_expr. func else {
472479 return ;
473480 } ;
@@ -486,10 +493,28 @@ fn check_method(checker: &Checker, call_expr: &ExprCall) {
486493 _ => return ,
487494 } ,
488495 [ "airflow" , "lineage" , "hook" , "HookLineageCollector" ] => match attr. as_str ( ) {
489- "create_dataset" => Replacement :: AttrName ( "create_asset" ) ,
490496 "add_input_dataset" => Replacement :: AttrName ( "add_input_asset" ) ,
491497 "add_output_dataset" => Replacement :: AttrName ( "add_output_asset" ) ,
492498 "collected_datasets" => Replacement :: AttrName ( "collected_assets" ) ,
499+ "create_dataset" => {
500+ if arguments. find_positional ( 0 ) . is_some ( ) {
501+ Replacement :: AttrNameWithMessage {
502+ attr_name : "create_asset" ,
503+ message : "Calling ``HookLineageCollector.create_asset`` with positional argument should raise an error" ,
504+ }
505+ } else {
506+ Replacement :: AttrName ( "create_asset" )
507+ }
508+ }
509+ "create_asset" => {
510+ if arguments. find_positional ( 0 ) . is_some ( ) {
511+ Replacement :: Message (
512+ "Calling ``HookLineageCollector.create_asset`` with positional argument should raise an error" ,
513+ )
514+ } else {
515+ return ;
516+ }
517+ }
493518 _ => return ,
494519 } ,
495520 [ "airflow" , "providers_manager" , "ProvidersManager" ] => match attr. as_str ( ) {
0 commit comments