コード例 #1
0
    def _check_executable_mismatch(self, shebang_token) -> None:
        is_executable = is_executable_file(self.filename)

        if is_executable and shebang_token is None:
            self.add_violation(
                ShebangViolation(
                    text='file is executable but no shebang is present', ), )

        if not is_executable and shebang_token is not None:
            self.add_violation(
                ShebangViolation(
                    text='shebang is present but the file is not executable',
                ), )
コード例 #2
0
    def _check_executable_mismatch(
        self,
        token: tokenize.TokenInfo,
        *,
        is_shebang: bool,
    ) -> None:
        if is_windows() or self.filename == STDIN:
            # Windows does not have this concept of "executable" file.
            # The same for STDIN inputs.
            return

        is_executable = is_executable_file(self.filename)
        if is_executable and not is_shebang:
            self.add_violation(
                ShebangViolation(
                    text='file is executable but no shebang is present', ), )
        elif not is_executable and is_shebang:
            self.add_violation(
                ShebangViolation(
                    text='shebang is present but the file is not executable',
                ), )