Skip to content

Commit

Permalink
move TypedDict classes to schemas.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Bizordec committed Oct 29, 2024
1 parent f40fbd4 commit 9ff483d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
30 changes: 30 additions & 0 deletions src/slipcover/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Dict, List, NotRequired, Tuple, TypedDict

class CoverageMeta(TypedDict):
software: str
version: str
timestamp: str
branch_coverage: bool
show_contexts: bool

class CoverageSummary(TypedDict):
covered_lines: int
missing_lines: int
covered_branches: NotRequired[int]
missing_branches: NotRequired[int]
percent_covered: float

class CoverageFile(TypedDict):
executed_lines: List[int]
missing_lines: List[int]
executed_branches: NotRequired[List[Tuple[int, int]]]
missing_branches: NotRequired[List[Tuple[int, int]]]
summary: CoverageSummary

class Coverage(TypedDict):
meta: CoverageMeta
files: Dict[str, CoverageFile]
summary: CoverageSummary
30 changes: 3 additions & 27 deletions src/slipcover/slipcover.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,9 @@ def findlinestarts(co: types.CodeType):
findlinestarts = dis.findlinestarts

if TYPE_CHECKING:
from typing import Dict, Iterable, Iterator, List, NotRequired, Optional, Tuple, TypedDict

class CoverageMeta(TypedDict):
software: str
version: str
timestamp: str
branch_coverage: bool
show_contexts: bool

class CoverageSummary(TypedDict):
covered_lines: int
missing_lines: int
covered_branches: NotRequired[int]
missing_branches: NotRequired[int]
percent_covered: float

class CoverageFile(TypedDict):
executed_lines: List[int]
missing_lines: List[int]
executed_branches: NotRequired[List[Tuple[int, int]]]
missing_branches: NotRequired[List[Tuple[int, int]]]
summary: CoverageSummary

class Coverage(TypedDict):
meta: CoverageMeta
files: Dict[str, CoverageFile]
summary: CoverageSummary
from typing import Dict, Iterable, Iterator, List, Optional, Tuple

from .schemas import Coverage

class SlipcoverError(Exception):
pass
Expand Down
2 changes: 1 addition & 1 deletion src/slipcover/xmlreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if TYPE_CHECKING:
from typing import Sequence, TypeVar

from slipcover.slipcover import Coverage, CoverageFile
from .schemas import Coverage, CoverageFile

SortableItem = TypeVar("SortableItem", bound=Sequence[Any])

Expand Down

0 comments on commit 9ff483d

Please sign in to comment.