docstr: The type of the definition.
  
  Here is an example of the value of this attribute.  Let's consider
  the following source.  As what is in ``variable`` is unambiguous
  to Jedi, :meth:`jedi.Script.goto_definitions` should return a list of
  definition for ``sys``, ``f``, ``C`` and ``x``.
  
  >>> from jedi import Script
  >>> source = '''
  ... import keyword
  ...
  ... class C:
  ...     pass
  ...
  ... class D:
  ...     pass
  ...
  ... x = D()
  ...
  ... def f():
  ...     pass
  ...
  ... for variable in [keyword, f, C, x]:
  ...     variable'''
  
  >>> script = Script(source)
  >>> defs = script.goto_definitions()
  
  Before showing what is in ``defs``, let's sort it by :attr:`line`
  so that it is easy to relate the result to the source code.
  
  >>> defs = sorted(defs, key=lambda d: d.line)
  >>> defs                           # doctest: +NORMALIZE_WHITESPACE
  [<Definition module keyword>, <Definition class C>,
   <Definition instance D>, <Definition def f>]
  
  Finally, here is what you can get from :attr:`type`:
  
  >>> defs = [str(d.type) for d in defs]  # It's unicode and in Py2 has u before it.
  >>> defs[0]
  'module'
  >>> defs[1]
  'class'
  >>> defs[2]
  'instance'
  >>> defs[3]
  'function'
docstr_tok: ["The","type","of","the","definition",".","Here","is","an","example","of","the","value","of","this","attribute",".","Let","'s","consider","the","following","source",".","As","what","is","in","``","variable","``","is","unambiguous","to","Jedi",",",":","meth",":","`","jedi.Script.goto_definitions","`","should","return","a","list","of","definition","for","``","sys","``",",","``","f","``",",","``","C","``","and","``","x","``",".",">",">",">","from","jedi","import","Script",">",">",">","source","=","``","'","...","import","keyword","...","...","class","C",":","...","pass","...","...","class","D",":","...","pass","...","...","x","=","D","(",")","...","...","def","f","(",")",":","...","pass","...","...","for","variable","in","[","keyword",",","f",",","C",",","x","]",":","...","variable","''","'",">",">",">","script","=","Script","(","source",")",">",">",">","defs","=","script.goto_definitions","(",")","Before","showing","what","is","in","``","defs","``",",","let","'s","sort","it","by",":","attr",":","`","line","`","so","that","it","is","easy","to","relate","the","result","to","the","source","code",".",">",">",">","defs","=","sorted","(","defs",",","key=lambda","d",":","d.line",")",">",">",">","defs","#","doctest",":","+NORMALIZE_WHITESPACE","[","<","Definition","module","keyword",">",",","<","Definition","class","C",">",",","<","Definition","instance","D",">",",","<","Definition","def","f",">","]","Finally",",","here","is","what","you","can","get","from",":","attr",":","`","type","`",":",">",">",">","defs","=","[","str","(","d.type",")","for","d","in","defs","]","#","It","'s","unicode","and","in","Py2","has","u","before","it",".",">",">",">","defs","[","0","]","'module'",">",">",">","defs","[","1","]","'class'",">",">",">","defs","[","2","]","'instance'",">",">",">","defs","[","3","]","'function","'"]
code: def type(self):
      """
      The type of the definition.
  
      Here is an example of the value of this attribute.  Let's consider
      the following source.  As what is in ``variable`` is unambiguous
      to Jedi, :meth:`jedi.Script.goto_definitions` should return a list of
      definition for ``sys``, ``f``, ``C`` and ``x``.
  
      >>> from jedi import Script
      >>> source = '''
      ... import keyword
      ...
      ... class C:
      ...     pass
      ...
      ... class D:
      ...     pass
      ...
      ... x = D()
      ...
      ... def f():
      ...     pass
      ...
      ... for variable in [keyword, f, C, x]:
      ...     variable'''
  
      >>> script = Script(source)
      >>> defs = script.goto_definitions()
  
      Before showing what is in ``defs``, let's sort it by :attr:`line`
      so that it is easy to relate the result to the source code.
  
      >>> defs = sorted(defs, key=lambda d: d.line)
      >>> defs                           # doctest: +NORMALIZE_WHITESPACE
      [<Definition module keyword>, <Definition class C>,
       <Definition instance D>, <Definition def f>]
  
      Finally, here is what you can get from :attr:`type`:
  
      >>> defs = [str(d.type) for d in defs]  # It's unicode and in Py2 has u before it.
      >>> defs[0]
      'module'
      >>> defs[1]
      'class'
      >>> defs[2]
      'instance'
      >>> defs[3]
      'function'
  
      """
      tree_name = self._name.tree_name
      resolve = False
      if tree_name is not None:
          # TODO move this to their respective names.
          definition = tree_name.get_definition()
          if (
              definition is not None
              and definition.type == "import_from"
              and tree_name.is_definition()
          ):
              resolve = True
  
      if isinstance(self._name, imports.SubModuleName) or resolve:
          for context in self._name.infer():
              return context.api_type
      return self._name.api_type
  
imports: import re
  from parso.python.tree import search_ancestor
  from jedi import settings
  from jedi.evaluate.utils import ignored, unite
  from jedi.cache import memoize_method
  from jedi.evaluate import imports
  from jedi.evaluate import compiled
  from jedi.evaluate.imports import ImportName
  from jedi.evaluate.context import instance
  from jedi.evaluate.context import ClassContext, FunctionExecutionContext
  from jedi.api.keywords import KeywordName
label_desc: Use image node_id 3 for calling the BaseDefinition obj's underlying member method code with example usage: obj.type() and returns: self, context