class_docstr: A wrapper for inspecting a JSON schema
class_docstr_tok: ["A","wrapper","for","inspecting","a","JSON","schema"]
code: def get_python_type_representation(
      self,
      for_type_hints: bool = False,
      altair_classes_prefix: Optional[str] = None,
      return_as_str: bool = True,
      additional_type_hints: Optional[List[str]] = None,
  ) -> Union[str, List[str]]:
      # This is a list of all types which can be used for the current SchemaInfo.
      # This includes Altair classes, standard Python types, etc.
      type_representations: List[str] = []
      if self.title:
          if for_type_hints:
              # To keep type hints simple, we only use the SchemaBase class
              # as the type hint for all classes which inherit from it.
              class_names = ["SchemaBase"]
              if self.title == "ExprRef":
                  # In these cases, a value parameter is also always accepted.
                  # We use the _Parameter to indicate this although this
                  # protocol would also pass for selection parameters but
                  # due to how the Parameter class is defined, it would be quite
                  # complex to further differentiate between a value and
                  # a selection parameter based on the type system (one could
                  # try to check for the type of the Parameter.param attribute
                  # but then we would need to write some overload signatures for
                  # api.param).
                  class_names.append("_Parameter")
              if self.title == "ParameterExtent":
                  class_names.append("_Parameter")
  
              prefix = (
                  ""
                  if not altair_classes_prefix
                  else altair_classes_prefix + "."
              )
              # If there is no prefix, it might be that the class is defined
              # in the same script and potentially after this line -> We use
              # deferred type annotations using quotation marks.
              if not prefix:
                  class_names = [f'"{n}"' for n in class_names]
              else:
                  class_names = [f"{prefix}{n}" for n in class_names]
              type_representations.extend(class_names)
          else:
              # use RST syntax for generated sphinx docs
              type_representations.append(
                  rst_syntax_for_class(self.title)
              )
  
      if self.is_empty():
          type_representations.append("Any")
      elif self.is_enum():
          type_representations.append(
              "Literal[{}]".format(", ".join(map(repr, self.enum)))
          )
      elif self.is_anyOf():
          type_representations.extend(
              [
                  s.get_python_type_representation(
                      for_type_hints=for_type_hints,
                      altair_classes_prefix=altair_classes_prefix,
                      return_as_str=False,
                  )
                  for s in self.anyOf
              ]
          )
      elif isinstance(self.type, list):
          options = []
          subschema = SchemaInfo(dict(**self.schema))
          for typ_ in self.type:
              subschema.schema["type"] = typ_
              options.append(
                  subschema.get_python_type_representation(
                      # We always use title if possible for nested objects
                      for_type_hints=for_type_hints,
                      altair_classes_prefix=altair_classes_prefix,
                  )
              )
          type_representations.extend(options)
      elif self.is_object():
          type_representations.append("dict")
      elif self.is_array():
          # A list is invariant in its type parameter. This means that e.g.
          # List[str] is not a subtype of List[Union[core.FieldName, str]]
          # and hence we would need to explicitly write out the combinations,
          # so in this case:
          # List[core.FieldName], List[str], List[core.FieldName, str]
          # However, this can easily explode to too many combinations.
          # Furthermore, we would also need to add additional entries
          # for e.g. int wherever a float is accepted which would lead to very
          # long code.
          # As suggested in the mypy docs,
          # https://mypy.readthedocs.io/en/stable/common_issues.html#variance,
          # we revert to using Sequence which works as well for lists and also
          # includes tuples which are also supported by the SchemaBase.to_dict
          # method. However, it is not entirely accurate as some sequences
          # such as e.g. a range are not supported by SchemaBase.to_dict but
          # this tradeoff seems worth it.
          type_representations.append(
              "Sequence[{}]".format(
                  self.child(self.items).get_python_type_representation(
                      for_type_hints=for_type_hints,
                      altair_classes_prefix=altair_classes_prefix,
                  )
              )
          )
      elif self.type in jsonschema_to_python_types:
          type_representations.append(
              jsonschema_to_python_types[self.type]
          )
      else:
          raise ValueError(
              "No Python type representation available for this schema"
          )
  
      # Shorter types are usually the more relevant ones, e.g. `str` instead
      # of `SchemaBase`. Output order from set is non-deterministic -> If
      # types have same length names, order would be non-deterministic as it is
      # returned from sort. Hence, we sort as well by type name as a tie-breaker,
      # see https://docs.python.org/3.10/howto/sorting.html#sort-stability-and-complex-sorts
      # for more infos.
      type_representations = sorted(
          # Using lower as we don't want to prefer uppercase such as "None" over
          # "str"
          set(flatten(type_representations)),
          key=lambda x: x.lower(),
      )  # Secondary sort
      type_representations = sorted(
          type_representations,
          key=len,
      )  # Primary sort
      if additional_type_hints:
          type_representations.extend(additional_type_hints)
  
      if return_as_str:
          type_representations_str = ", ".join(type_representations)
          # If it's not for_type_hints but instead for the docstrings, we don't want
          # to include Union as it just clutters the docstrings.
          if len(type_representations) > 1 and for_type_hints:
              type_representations_str = (
                  f"Union[{type_representations_str}]"
              )
          return type_representations_str
      else:
          return type_representations
  
imports: import keyword
  import re
  import subprocess
  import textwrap
  import urllib
  from typing import Any, Dict, Final, Iterable, List, Optional, Union
  from .schemapi import _resolve_references
label_desc: Use image node_id 5 for calling the SchemaInfo obj's underlying member method code with example usage: obj.get_python_type_representation(for_type_hints, altair_classes_prefix, return_as_str, additional_type_hints) and returns: type_representations_str, type_representations