Skip to content

Commit

Permalink
Add a few annotations (#160)
Browse files Browse the repository at this point in the history
...done while debugging the `...` issue
  • Loading branch information
max-sixty committed Feb 7, 2024
1 parent be09a3b commit d4e3f46
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pytest_accept/doctest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import re
import textwrap
Expand All @@ -6,7 +8,6 @@
from doctest import DocTestFailure
from itertools import zip_longest
from pathlib import Path
from typing import Dict, List

import pytest
from _pytest.doctest import DoctestItem, MultipleDoctestFailures
Expand All @@ -20,11 +21,11 @@
# that pytest reports and the line numbers of the mutated file in subsequent tests. An
# alternative is a static with the updated file, but that seems even heavier.

# Dict of {path: list of (location, new code)}
failed_doctests: Dict[Path, List[DocTestFailure]] = defaultdict(list)
# dict of {path: list of (location, new code)}
failed_doctests: dict[Path, list[DocTestFailure]] = defaultdict(list)

# Dict of filename to hashes, so we don't overwrite a changed file
file_hashes: Dict[Path, int] = {}
# dict of filename to hashes, so we don't overwrite a changed file
file_hashes: dict[Path, int] = {}


def pytest_collect_file(path, parent):
Expand Down Expand Up @@ -57,7 +58,9 @@ def pytest_runtest_makereport(item, call):
return outcome.get_result()


def _snapshot_start_line(failure):
def _snapshot_start_line(failure: DocTestFailure) -> int:

assert failure.test.lineno is not None
return (
failure.test.lineno
+ failure.example.lineno
Expand Down

0 comments on commit d4e3f46

Please sign in to comment.