(
fragment: tuple[bool, int, list[str]],
filename: str,
colors: TermColors,
summary: Optional[Summary],
misspellings: dict[str, Misspelling],
ignore_words_cased: set[str],
exclude_lines: set[str],
word_regex: Pattern[str],
ignore_word_regex: Optional[Pattern[str]],
uri_regex: Pattern[str],
uri_ignore_words: set[str],
context: Optional[tuple[int, int]],
options: argparse.Namespace,
)
| 935 | |
| 936 | |
| 937 | def parse_lines( |
| 938 | fragment: tuple[bool, int, list[str]], |
| 939 | filename: str, |
| 940 | colors: TermColors, |
| 941 | summary: Optional[Summary], |
| 942 | misspellings: dict[str, Misspelling], |
| 943 | ignore_words_cased: set[str], |
| 944 | exclude_lines: set[str], |
| 945 | word_regex: Pattern[str], |
| 946 | ignore_word_regex: Optional[Pattern[str]], |
| 947 | uri_regex: Pattern[str], |
| 948 | uri_ignore_words: set[str], |
| 949 | context: Optional[tuple[int, int]], |
| 950 | options: argparse.Namespace, |
| 951 | ) -> tuple[int, bool, list[tuple[int, str, str]]]: |
| 952 | bad_count = 0 |
| 953 | changed = False |
| 954 | changes_made: list[tuple[int, str, str]] = [] |
| 955 | |
| 956 | _, fragment_line_number, lines = fragment |
| 957 | |
| 958 | for i, line in enumerate(lines): |
| 959 | line = line.rstrip() |
| 960 | if not line or line in exclude_lines: |
| 961 | continue |
| 962 | line_number = fragment_line_number + i |
| 963 | |
| 964 | extra_words_to_ignore = set() |
| 965 | match = ( |
| 966 | inline_ignore_regex.search(line) if codespell_ignore_tag in line else None |
| 967 | ) |
| 968 | if match: |
| 969 | extra_words_to_ignore = set( |
| 970 | filter(None, (match.group("words") or "").split(",")) |
| 971 | ) |
| 972 | if not extra_words_to_ignore: |
| 973 | continue |
| 974 | |
| 975 | fixed_words = set() |
| 976 | asked_for = set() |
| 977 | |
| 978 | # If all URI spelling errors will be ignored, erase any URI before |
| 979 | # extracting words. Otherwise, apply ignores after extracting words. |
| 980 | # This ensures that if a URI ignore word occurs both inside a URI and |
| 981 | # outside, it will still be a spelling error. |
| 982 | if "*" in uri_ignore_words: |
| 983 | line = uri_regex.sub(" ", line) |
| 984 | check_matches = extract_words_iter(line, word_regex, ignore_word_regex) |
| 985 | if "*" not in uri_ignore_words: |
| 986 | check_matches = apply_uri_ignore_words( |
| 987 | check_matches, |
| 988 | line, |
| 989 | word_regex, |
| 990 | ignore_word_regex, |
| 991 | uri_regex, |
| 992 | uri_ignore_words, |
| 993 | ) |
| 994 | for match in check_matches: |
no test coverage detected
searching dependent graphs…