Skip to content

Commit

Permalink
chore: py3.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Negin-Ulster committed Dec 30, 2022
1 parent 8739194 commit eb0953f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/syrupy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
dataclass,
field,
)
from functools import cached_property
from gettext import (
gettext,
ngettext,
Expand Down Expand Up @@ -70,6 +69,9 @@ class SnapshotReport:
used: "SnapshotFossils" = field(default_factory=SnapshotFossils)
_provided_test_paths: Dict[str, List[str]] = field(default_factory=dict)
_keyword_expressions: Set["Expression"] = field(default_factory=set)
_collected_items_by_nodeid: Dict[str, "pytest.Item"] = field(
default_factory=dict, init=False
)

@property
def update_snapshots(self) -> bool:
Expand All @@ -83,14 +85,11 @@ def warn_unused_snapshots(self) -> bool:
def include_snapshot_details(self) -> bool:
return bool(self.options.include_snapshot_details)

@cached_property
def _collected_items_by_nodeid(self) -> Dict[str, "pytest.Item"]:
return {
getattr(item, "nodeid"): item for item in self.collected_items # noqa: B009
}

def __post_init__(self) -> None:
self.__parse_invocation_args()
self._collected_items_by_nodeid = {
getattr(item, "nodeid"): item for item in self.collected_items # noqa: B009
}

# We only need to discover snapshots once per test file, not once per assertion.
locations_discovered: DefaultDict[str, Set[Any]] = defaultdict(set)
Expand Down

0 comments on commit eb0953f

Please sign in to comment.