(module (expression_statement (assignment left: (identifier) @name) @definition.constant))

(class_definition
  name: (identifier) @name) @definition.class

(function_definition
  name: (identifier) @name) @definition.function

(parameters
  (identifier) @name) @definition.parameter

(assignment
  left: (identifier) @name) @definition.variable

(import_statement
  name: (dotted_name) @name) @reference.module

(import_from_statement
  module_name: (dotted_name) @name) @reference.module

(import_from_statement
  name: (dotted_name) @name) @reference.import

(call
  function: (identifier) @name) @reference.call

[
  (binary_operator left: (identifier) @name)
  (binary_operator right: (identifier) @name)
  (return_statement (identifier) @name)
  (argument_list (identifier) @name)
  (assignment right: (identifier) @name)
  (subscript value: (identifier) @name)
  (comparison_operator (identifier) @name)
  (conditional_expression (identifier) @name)
] @reference.variable

(type
  (identifier) @name) @reference.type
