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 f77f54d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/syrupy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_syrupy: Optional["SnapshotSession"] = None


@lru_cache
@lru_cache(maxsize=1)
def __import_extension(value: Optional[str]) -> Any:
if not value:
return DEFAULT_EXTENSION
Expand Down
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

1 comment on commit f77f54d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: f77f54d Previous: 23cca84 Ratio
benchmarks/test_1000x.py::test_1000x_reads 0.720702320398355 iter/sec (stddev: 0.06338653299043454) 0.6754078596653935 iter/sec (stddev: 0.06391877117699159) 0.94
benchmarks/test_1000x.py::test_1000x_writes 0.6854346249718773 iter/sec (stddev: 0.1859948301743253) 0.6345993135561808 iter/sec (stddev: 0.23174880874067105) 0.93
benchmarks/test_standard.py::test_standard 0.6744553608057112 iter/sec (stddev: 0.07965752287666655) 0.6315599143065584 iter/sec (stddev: 0.0923523543680502) 0.94

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.