code: def _iter_incorrect_new_session_usages(
      path: pathlib.Path,
  ) -> typing.Iterator[ast.FunctionDef]:
      """Check NEW_SESSION usages outside functions decorated with provide_session."""
      for node in ast.walk(
          ast.parse(path.read_text("utf-8"), str(path))
      ):
          if not isinstance(node, ast.FunctionDef):
              continue
          session = _get_session_arg_and_default(node.args)
          if session is None or session.default is None:
              continue  # No session argument or the argument has no default, we're good.
          if _is_decorated_correctly(node.decorator_list):
              continue  # Has @provide_session so the default is expected.
          default_kind = _is_new_session_or_none(session.default)
          if default_kind is None:
              continue  # Default value is not NEW_SESSION or None.
          if (
              default_kind == _SessionDefault.none
              and _annotation_has_none(session.argument.annotation)
          ):
              continue  # None is OK if the argument is explicitly typed as None.
          yield node
  
file_path: airflow/scripts/ci/pre_commit/pre_commit_new_session_in_provide_session.py
imports: from __future__ import annotations
  import ast
  import enum
  import itertools
  import pathlib
  import sys
  import typing
label_desc: Use image node_id 5 for calling a global function with example usage: _iter_incorrect_new_session_usages(path) without return types