コード例 #1
0
ファイル: command.py プロジェクト: zhenyulin/coconut
 def run_mypy(self, paths=(), code=None):
     """Run MyPy with arguments."""
     if self.mypy:
         set_mypy_path(stub_dir)
         from coconut.command.mypy import mypy_run
         args = list(paths) + self.mypy_args
         if code is not None:
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             if code is None or line not in self.mypy_errs:
                 printerr(line)
             if line not in self.mypy_errs:
                 self.mypy_errs.append(line)
             self.register_error(errmsg="MyPy error")
コード例 #2
0
ファイル: command.py プロジェクト: Boscillator/coconut
 def run_mypy(self, paths=[], code=None):
     """Run MyPy with arguments."""
     set_mypy_path(stub_dir)
     if self.mypy:
         from coconut.command.mypy import mypy_run
         args = paths + self.mypy_args
         if code is not None:
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             if code is None or line not in self.mypy_errs:
                 if is_err:
                     printerr(line)
                 else:
                     print(line)
             if line not in self.mypy_errs:
                 self.mypy_errs.append(line)
コード例 #3
0
ファイル: command.py プロジェクト: pyzh/coconut
 def run_mypy(self, paths=[], code=None):
     """Run MyPy with arguments."""
     set_mypy_path(stub_dir)
     if self.mypy:
         from coconut.command.mypy import mypy_run
         args = paths + self.mypy_args
         if code is not None:
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             if code is None or line not in self.mypy_errs:
                 if is_err:
                     printerr(line)
                 else:
                     print(line)
             if line not in self.mypy_errs:
                 self.mypy_errs.append(line)
コード例 #4
0
ファイル: command.py プロジェクト: darwinz/coconut
 def run_mypy(self, paths=(), code=None):
     """Run MyPy with arguments."""
     if self.mypy:
         set_mypy_path()
         from coconut.command.mypy import mypy_run
         args = list(paths) + self.mypy_args
         if code is not None:  # interpreter
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             logger.log("[MyPy]", line)
             if line.startswith(mypy_silent_err_prefixes):
                 if code is None:  # file
                     printerr(line)
                     self.register_error(errmsg="MyPy error")
             elif not line.startswith(mypy_silent_non_err_prefixes):
                 if code is None:  # file
                     printerr(line)
                     if any(infix in line for infix in mypy_err_infixes):
                         self.register_error(errmsg="MyPy error")
                 if line not in self.mypy_errs:
                     if code is not None:  # interpreter
                         printerr(line)
                     self.mypy_errs.append(line)
コード例 #5
0
ファイル: command.py プロジェクト: darwinz/coconut
    def set_mypy_args(self, mypy_args=None):
        """Set MyPy arguments."""
        if mypy_args is None:
            self.mypy_args = None

        elif mypy_install_arg in mypy_args:
            if mypy_args != [mypy_install_arg]:
                raise CoconutException("'--mypy install' cannot be used alongside other --mypy arguments")
            stub_dir = set_mypy_path()
            logger.show_sig("Successfully installed MyPy stubs into " + repr(stub_dir))
            self.mypy_args = None

        else:
            self.mypy_args = list(mypy_args)

            if not any(arg.startswith("--python-version") for arg in self.mypy_args):
                self.mypy_args += [
                    "--python-version",
                    ver_tuple_to_str(get_target_info_smart(self.comp.target, mode="mypy")),
                ]

            if not any(arg.startswith("--python-executable") for arg in self.mypy_args):
                self.mypy_args += [
                    "--python-executable",
                    sys.executable,
                ]

            add_mypy_args = default_mypy_args + (verbose_mypy_args if logger.verbose else ())

            for arg in add_mypy_args:
                no_arg = invert_mypy_arg(arg)
                arg_prefixes = (arg,) + ((no_arg,) if no_arg is not None else ())
                if not any(arg.startswith(arg_prefixes) for arg in self.mypy_args):
                    self.mypy_args.append(arg)

            logger.log("MyPy args:", self.mypy_args)
            self.mypy_errs = []