custom post types – Error function query

I’m trying to show Custom post type called CursosTL but i’m Getting this error:

The code:

function elc_cursos_en_el_blog() {

if ( $query->is_home() && $query->is_main_query() ) {
$query->set( ‘post_type’, array( ‘post’, ‘CursoTL’ ));
}

}
add_action( ‘pre_get_posts’, ‘elc_cursos_en_el_blog’ );

The error:

Uncaught Error: Call to a member function is_home() on null in wp-content/plugins/cursos_temlean/cursos_temlean.php:240
Stack trace:
#0 wp-includes/class-wp-hook.php(287): elc_cursos_en_el_blog(Object(WP_Query))
#1 wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array)
#2 wp-includes/plugin.php(551): WP_Hook->do_action(Array)
#3 wp-includes/class-wp-query.php(1779): do_action_ref_array(‘pre_get_posts’, Array)
#4 wp-includes/class-wp-query.php(3448): WP_Query->get_posts()
#5 wp-includes/post.php(2065): WP_Query->query(Array)
#6 wp-content/plugins/amp/includes/admin/functions.php(

Any help?