Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop shuffling ranger_handles and incident_types #1368

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ims/model/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def freezeStrings(strings: Iterable[str]) -> frozenset[str]:
return frozenset(strings)


def dedupeStrings(strings: Iterable[str]) -> tuple[str, ...]:
deduped = {s: None for s in strings}
srabraham marked this conversation as resolved.
Show resolved Hide resolved
return tuple(s for s in deduped)


def normalizeDateTime(dateTime: DateTime) -> DateTime:
"""
Shave some precision off of DateTimes, since it may not round-trip well
Expand Down
6 changes: 3 additions & 3 deletions src/ims/model/_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from ims.ext.attr import sorted_tuple

from ._convert import freezeIntegers, freezeStrings, normalizeDateTime
from ._convert import dedupeStrings, freezeIntegers, normalizeDateTime
from ._entry import ReportEntry
from ._location import Location
from ._priority import IncidentPriority
Expand Down Expand Up @@ -57,8 +57,8 @@ class Incident(ReplaceMixIn):
priority: IncidentPriority
summary: str | None
location: Location
rangerHandles: frozenset[str] = field(converter=freezeStrings)
incidentTypes: frozenset[str] = field(converter=freezeStrings)
rangerHandles: tuple[str, ...] = field(converter=dedupeStrings)
incidentTypes: tuple[str, ...] = field(converter=dedupeStrings)
reportEntries: Sequence[ReportEntry] = field(
converter=sortAndFreezeReportEntries
)
Expand Down
6 changes: 3 additions & 3 deletions src/ims/model/_ranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from ims.ext.enum import Names, auto, unique

from ._convert import freezeStrings
from ._convert import dedupeStrings
from ._replace import ReplaceMixIn


Expand Down Expand Up @@ -73,8 +73,8 @@ class Ranger(ReplaceMixIn):
handle: str
name: str
status: RangerStatus
email: frozenset[str] = field(
converter=freezeStrings, default=frozenset[str]()
email: tuple[str, ...] = field(
converter=dedupeStrings, default=tuple[str, ...]()
)
enabled: bool
directoryID: str | None
Expand Down
Loading