# Path: dev_tools/env_tools.py
# def get_unhidden_ungenerated_python_files(directory: str) -> Iterable[str]:
# def create_virtual_env(venv_path: str,
#                        requirements_paths: Iterable[str],
#                        python_path: str,
#                        verbose: bool) -> None:
# def prepare_temporary_test_environment(
#         destination_directory: str,
#         repository: GithubRepository,
#         pull_request_number: Optional[int],
#         verbose: bool,
#         env_name: str = '.test_virtualenv',
#         python_path: str = '/usr/bin/python3.5',
#         commit_ids_known_callback: Callable[[PreparedEnv], None] = None
# ) -> PreparedEnv:
# 
# Path: dev_tools/incremental_coverage.py
# IGNORED_FILE_PATTERNS = [
#     r'^dev_tools/.+',  # Environment-heavy code.
#     r'^.+_pb2(_grpc)?\.py$',  # Auto-generated protobuf code.
#     r'^setup\.py$',  # Installation code.
#     r'^docs/.+$',  # Documentation
# ]
# IGNORED_LINE_PATTERNS = [
#     # Imports often uncovered due to version checks and type checking blocks.
#     r'^import .+$',
#     r'^from .+ import .+$',
#     # Else lines are redundant w.r.t. other lines.
#     r'^else:$',
#     # Lines that are only invoked when running the file as the main file.
#     r'^main\(.+$',
#     r'^app.run\(main\)$',
#     # Empty method definitions.
#     r'^pass$',
#     # Code explicitly marked as not implemented.
#     r'raise NotImplementedError\(.+',
# ]
# EXPLICIT_OPT_OUT_COMMENT = '#coverage:ignore'
# def diff_to_new_interesting_lines(unified_diff_lines: List[str]
#                                   ) -> Dict[int, str]:
# def fix_line_from_coverage_file(line):
# def get_incremental_uncovered_lines(abs_path: str,
#                                     base_commit: str,
#                                     actual_commit: Optional[str]
#                                     ) -> List[Tuple[int, str, str]]:
# def line_content_counts_as_uncovered_manual(content: str) -> bool:
# def determine_ignored_lines(content: str) -> Set[int]:
# def naive_find_end_of_scope(lines: List[str], i: int) -> int:
# def line_counts_as_uncovered(line: str,
#                              is_from_cover_annotation_file: bool) -> bool:
# def is_applicable_python_file(rel_path: str) -> bool:
# def check_for_uncovered_lines(env: env_tools.PreparedEnv) -> int:
# 
# Path: dev_tools/check.py
# class CheckResult:
# class Check(metaclass=abc.ABCMeta):
#     def __init__(self,
#                  check: 'Check',
#                  success: bool,
#                  message: str,
#                  unexpected_error: Optional[Exception]) -> None:
#     def __str__(self):
#     def __init__(self, *dependencies):
#     def command_line_switch(self) -> str:
#     def context(self) -> str:
#     def perform_check(self,
#                       env: env_tools.PreparedEnv,
#                       verbose: bool) -> Tuple[bool, str]:
#     def run(self,
#             env: env_tools.PreparedEnv,
#             verbose: bool,
#             previous_failures: Set['Check']) -> CheckResult:
#     def pick_env_and_run_and_report(self,
#                                     env: env_tools.PreparedEnv,
#                                     verbose: bool,
#                                     previous_failures: Set['Check']
#                                     ) -> CheckResult:


from dev_tools import env_tools, incremental_coverage, check
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



class IncrementalCoverageCheck(check.Check):
    """Checks if touched lines are covered by tests.

    This check must run after the pytest check, because that check is what
    computes the coverage files used by this check.
    """
    def command_line_switch(self):
        return 'incremental-coverage'

    def context(self):
        return 'incremental coverage'

    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):

# Path: dev_tools/env_tools.py
# def get_unhidden_ungenerated_python_files(directory: str) -> Iterable[str]:
# def create_virtual_env(venv_path: str,
#                        requirements_paths: Iterable[str],
#                        python_path: str,
#                        verbose: bool) -> None:
# def prepare_temporary_test_environment(
#         destination_directory: str,
#         repository: GithubRepository,
#         pull_request_number: Optional[int],
#         verbose: bool,
#         env_name: str = '.test_virtualenv',
#         python_path: str = '/usr/bin/python3.5',
#         commit_ids_known_callback: Callable[[PreparedEnv], None] = None
# ) -> PreparedEnv:
# 
# Path: dev_tools/incremental_coverage.py
# IGNORED_FILE_PATTERNS = [
#     r'^dev_tools/.+',  # Environment-heavy code.
#     r'^.+_pb2(_grpc)?\.py$',  # Auto-generated protobuf code.
#     r'^setup\.py$',  # Installation code.
#     r'^docs/.+$',  # Documentation
# ]
# IGNORED_LINE_PATTERNS = [
#     # Imports often uncovered due to version checks and type checking blocks.
#     r'^import .+$',
#     r'^from .+ import .+$',
#     # Else lines are redundant w.r.t. other lines.
#     r'^else:$',
#     # Lines that are only invoked when running the file as the main file.
#     r'^main\(.+$',
#     r'^app.run\(main\)$',
#     # Empty method definitions.
#     r'^pass$',
#     # Code explicitly marked as not implemented.
#     r'raise NotImplementedError\(.+',
# ]
# EXPLICIT_OPT_OUT_COMMENT = '#coverage:ignore'
# def diff_to_new_interesting_lines(unified_diff_lines: List[str]
#                                   ) -> Dict[int, str]:
# def fix_line_from_coverage_file(line):
# def get_incremental_uncovered_lines(abs_path: str,
#                                     base_commit: str,
#                                     actual_commit: Optional[str]
#                                     ) -> List[Tuple[int, str, str]]:
# def line_content_counts_as_uncovered_manual(content: str) -> bool:
# def determine_ignored_lines(content: str) -> Set[int]:
# def naive_find_end_of_scope(lines: List[str], i: int) -> int:
# def line_counts_as_uncovered(line: str,
#                              is_from_cover_annotation_file: bool) -> bool:
# def is_applicable_python_file(rel_path: str) -> bool:
# def check_for_uncovered_lines(env: env_tools.PreparedEnv) -> int:
# 
# Path: dev_tools/check.py
# class CheckResult:
# class Check(metaclass=abc.ABCMeta):
#     def __init__(self,
#                  check: 'Check',
#                  success: bool,
#                  message: str,
#                  unexpected_error: Optional[Exception]) -> None:
#     def __str__(self):
#     def __init__(self, *dependencies):
#     def command_line_switch(self) -> str:
#     def context(self) -> str:
#     def perform_check(self,
#                       env: env_tools.PreparedEnv,
#                       verbose: bool) -> Tuple[bool, str]:
#     def run(self,
#             env: env_tools.PreparedEnv,
#             verbose: bool,
#             previous_failures: Set['Check']) -> CheckResult:
#     def pick_env_and_run_and_report(self,
#                                     env: env_tools.PreparedEnv,
#                                     verbose: bool,
#                                     previous_failures: Set['Check']
#                                     ) -> CheckResult:


# Path: dev_tools/check_incremental_coverage.py
from dev_tools import env_tools, incremental_coverage, check

# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



class IncrementalCoverageCheck(check.Check):
    """Checks if touched lines are covered by tests.

    This check must run after the pytest check, because that check is what
    computes the coverage files used by this check.
    """
    def command_line_switch(self):
        return 'incremental-coverage'

    def context(self):
        return 'incremental coverage'

    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):

        uncovered_count = incremental_coverage.check_for_uncovered_lines(env)