nodes: 0, module; 1, function_definition; 2, function_name:blacken; 3, parameters; 4, block; 5, identifier:c; 6, expression_statement; 7, if_statement; 8, comment:# Install, allowing config override of hardcoded default version; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# Execute our blacken task, with diff + check, which will both error; 13, comment:# and emit diffs.; 14, expression_statement; 15, comment:"""
      Install and execute ``black`` under appropriate circumstances, with diffs.
  
      Installs and runs ``black`` under Python 3.6 (the first version it
      supports). Since this sort of CI based task only needs to run once per
      commit (formatting is not going to change between interpreters) this seems
      like a worthwhile tradeoff.
  
      This task uses black's ``--check`` and ``--fail`` flags, so not only will
      the build fail if it does not conform, but contributors can see exactly
      what they need to change. This is intended as a hedge against the fact that
      not all contributors will be using Python 3.6+.
      """; 16, not_operator; 17, block; 18, assignment; 19, assignment; 20, call; 21, call; 22, call; 23, expression_statement; 24, expression_statement; 25, return_statement; 26, identifier:config; 27, call; 28, identifier:version; 29, call; 30, attribute; 31, argument_list; 32, attribute; 33, argument_list; 34, attribute; 35, argument_list; 36, assignment; 37, call; 38, attribute; 39, argument_list; 40, attribute; 41, argument_list; 42, identifier:c; 43, identifier:run; 44, call; 45, identifier:checks; 46, identifier:blacken; 47, identifier:c; 48, keyword_argument; 49, keyword_argument; 50, identifier:PYTHON; 51, identifier:startswith; 52, string:"3.6"; 53, identifier:msg; 54, call; 55, identifier:print; 56, argument_list; 57, call; 58, identifier:get; 59, string:"black"; 60, dictionary; 61, identifier:config; 62, identifier:get; 63, string:"version"; 64, string:"18.5b0"; 65, attribute; 66, argument_list; 67, identifier:check; 68, True; 69, identifier:diff; 70, True; 71, attribute; 72, argument_list; 73, identifier:msg; 74, keyword_argument; 75, attribute; 76, argument_list; 77, string:"pip install black=={}"; 78, identifier:format; 79, identifier:version; 80, string:"Not blackening, since Python {} != Python 3.6"; 81, identifier:format; 82, identifier:PYTHON; 83, identifier:file; 84, attribute; 85, attribute; 86, identifier:get; 87, string:"travis"; 88, dictionary; 89, identifier:sys; 90, identifier:stderr; 91, identifier:c; 92, identifier:config
code: def blacken(c):
      """
      Install and execute ``black`` under appropriate circumstances, with diffs.
  
      Installs and runs ``black`` under Python 3.6 (the first version it
      supports). Since this sort of CI based task only needs to run once per
      commit (formatting is not going to change between interpreters) this seems
      like a worthwhile tradeoff.
  
      This task uses black's ``--check`` and ``--fail`` flags, so not only will
      the build fail if it does not conform, but contributors can see exactly
      what they need to change. This is intended as a hedge against the fact that
      not all contributors will be using Python 3.6+.
      """
      if not PYTHON.startswith("3.6"):
          msg = "Not blackening, since Python {} != Python 3.6".format(PYTHON)
          print(msg, file=sys.stderr)
          return
      # Install, allowing config override of hardcoded default version
      config = c.config.get("travis", {}).get("black", {})
      version = config.get("version", "18.5b0")
      c.run("pip install black=={}".format(version))
      # Execute our blacken task, with diff + check, which will both error
      # and emit diffs.
      checks.blacken(c, check=True, diff=True)