class_docstr: Provides operations upon an Alembic script directory.
  
  This object is useful to get information as to current revisions,
  most notably being able to get at the "head" revision, for schemes
  that want to test if the current revision in the database is the most
  recent::
  
      from alembic.script import ScriptDirectory
      from alembic.config import Config
      config = Config()
      config.set_main_option("script_location", "myapp:migrations")
      script = ScriptDirectory.from_config(config)
  
      head_revision = script.get_current_head()
class_docstr_tok: ["Provides","operations","upon","an","Alembic","script","directory",".","This","object","is","useful","to","get","information","as","to","current","revisions",",","most","notably","being","able","to","get","at","the","``","head","''","revision",",","for","schemes","that","want","to","test","if","the","current","revision","in","the","database","is","the","most","recent",":",":","from","alembic.script","import","ScriptDirectory","from","alembic.config","import","Config","config","=","Config","(",")","config.set_main_option","(","``","script_location","''",",","``","myapp",":","migrations","''",")","script","=","ScriptDirectory.from_config","(","config",")","head_revision","=","script.get_current_head","(",")"]
docstr: Convert a symbolic revision, i.e. 'head' or 'base', into
  an actual revision number.
docstr_tok: ["Convert","a","symbolic","revision",",","i.e",".","'head","'","or","'base","'",",","into","an","actual","revision","number","."]
code: def as_revision_number(
      self, id_: Optional[str]
  ) -> Optional[Union[str, Tuple[str, ...]]]:
      """Convert a symbolic revision, i.e. 'head' or 'base', into
      an actual revision number."""
  
      with self._catch_revision_errors():
          rev, branch_name = self.revision_map._resolve_revision_number(
              id_
          )
  
      if not rev:
          # convert () to None
          return None
      elif id_ == "heads":
          return rev
      else:
          return rev[0]
  
imports: from __future__ import annotations
  from contextlib import contextmanager
  import datetime
  import os
  import re
  import shutil
  import sys
  from types import ModuleType
  from typing import Any
  from typing import cast
  from typing import Iterator
  from typing import List
  from typing import Mapping
  from typing import Optional
  from typing import Sequence
  from typing import Set
  from typing import Tuple
  from typing import TYPE_CHECKING
  from typing import Union
  from .None import revision
  from .None import write_hooks
  from ..None import util
  from ..runtime import migration
  from ..util import compat
  from ..util import not_none
label_desc: Use image node_id 11 for calling the ScriptDirectory obj's underlying member method code with example usage: obj.as_revision_number(id_) and returns: None, rev, rev