class_docstr: A custom command to run MyPy on the project sources.
class_docstr_tok: ["A","custom","command","to","run","MyPy","on","the","project","sources","."]
code: def run(self):
      # import here (after the setup_requires list is loaded),
      # otherwise a module-not-found error is thrown
      import mypy.api
  
      excluded_folders = [
          str(p.parent.relative_to(ROOT))
          for p in ROOT.glob("src/**/.typeunsafe")
      ]
  
      if len(excluded_folders) > 0:
          print(
              "The following folders contain a `.typeunsafe` marker file "
              "and will *not* be type-checked with `mypy`:"
          )
      for folder in excluded_folders:
          print(f"  {folder}")
  
      args = [str(ROOT / "src")]
      for folder in excluded_folders:
          args.append("--exclude")
          args.append(folder)
  
      std_out, std_err, exit_code = mypy.api.run(args)
  
      print(std_out, file=sys.stdout)
      print(std_err, file=sys.stderr)
  
      if exit_code:
          error_msg = dedent(
              f"""
                  Mypy command
  
                      mypy {" ".join(args)}
  
                  returned a non-zero exit code. Fix the type errors listed above
                  and then run
  
                      python setup.py type_check
  
                  in order to validate your fixes.
                  """
          ).lstrip()
  
          print(error_msg, file=sys.stderr)
          sys.exit(exit_code)
  
file_path: gluonts/setup.py
imports: import distutils.cmd
  import sys
  from pathlib import Path
  from textwrap import dedent
  from setuptools import setup
label_desc: Use image node_id 3 for calling the TypeCheckCommand obj's underlying member method code with example usage: obj.run() without return types