def run()

in tools/tensorflow_docs/tools/nblint/linter.py [0:0]


  def run(self, path: pathlib.Path, lint_dict: LintDict,
          user_args_dict: Dict[str, Any]) -> "LinterStatus":
    """Multiple hooks provided to run tests at specific points.

    Args:
      path: `pathlib.Path` of notebook to run lints against.
      lint_dict: A dictionary containing the lint styles.
      user_args_dict: Dictionary of user-defined args passed to lint callback.

    Returns:
      LinterStatus: Provides status and reporting of lint tests for a notebook.
    """
    data, source = self._load_notebook(path)
    if not data:
      return False

    # Args passed to lint callback function.
    lint_args = {
        "cell_data": None,  # Added per-cell in _run_lint_group.
        "cell_source": None,  # Added per-cell in _run_lint_group.
        "file_data": data,
        "file_source": source,
        "path": path,
        "user": user_args_dict
    }

    status = LinterStatus(path, verbose=self.verbose)

    # File-level scope.
    # Lint run once for the file.
    for lint in lint_dict[decorator.Options.Scope.FILE][
        decorator.Options.Cond.ANY]:
      run_status = self._run_lint(lint, lint_args, status)
      status.add_entry(lint, run_status)

    # Cell-level scope.
    # These lints run on each cell, then return a cumulative result.
    for scope in [
        decorator.Options.Scope.CELLS, decorator.Options.Scope.CODE,
        decorator.Options.Scope.TEXT
    ]:
      for cond in decorator.Options.Cond:
        lints = lint_dict[scope][cond]
        for lint in lints:
          # Run lint group and create a separate group status.
          is_success, cond_fail_msgs = self._run_lint_group(
              lint, lint_args, data, status)
          run_status = Linter.RunLintStatus(is_success, lint, lint_args)
          status.add_entry(lint, run_status, group=lint.name)
          if not is_success:
            # Once group status is known, log any conditional messages.
            for msg in cond_fail_msgs:
              # Grab stack trace and carry on.
              f = io.StringIO()
              traceback.print_exc(file=f)
              trace = f.getvalue()
              # Add any non-conditional failure messages to queue. Will de-dup.
              status.log_lint_message(msg, lint, verbose_msg=trace)

    return status