code: def _is_new_session_or_none(
      value: ast.expr,
  ) -> _SessionDefault | None:
      """Whether an expression is NEW_SESSION.
  
      Old code written before the introduction of NEW_SESSION (and even some new
      if the contributor wasn't made aware of the addition) generally uses None
      as the default value, so we add that to the check as well.
      """
      if isinstance(value, ast.Constant) and value.value is None:
          return _SessionDefault.none
      if isinstance(value, ast.Name) and value.id == "NEW_SESSION":
          return _SessionDefault.new_session
      # It's possible to do FOO = NEW_SESSION and reference FOO to work around
      # this check, but let's rely on reviewers to catch this kind of shenanigans.
      return None
  
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 2 for calling a global function with example usage: _is_new_session_or_none(value) and returns: None, _SessionDefault, _SessionDefault