Skip to content

Commit 927cecc

Browse files
change Event to a frozen dataclass (#592)
1 parent d74126a commit 927cecc

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# default owners
2-
* @albrja @collijk @hussain-jafari @patricktnast @rmudambi @stevebachmeier
2+
* @albrja @hussain-jafari @patricktnast @rmudambi @stevebachmeier

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
**3.3.7 - 02/26/25**
1+
**3.3.7 - 02/27/25**
22

3+
- Change Event class to a frozen dataclass
34
- Type-hinting: Fix mypy errors in tests/framework/population/test_population_view.py
45

56
**3.3.6 - 02/25/25**

src/vivarium/framework/event.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
from __future__ import annotations
3030

3131
from collections.abc import Callable
32+
from dataclasses import dataclass
3233
from datetime import datetime, timedelta
33-
from typing import TYPE_CHECKING, Any, NamedTuple
34+
from typing import TYPE_CHECKING, Any
3435

3536
import pandas as pd
3637

@@ -42,16 +43,16 @@
4243
from vivarium.framework.engine import Builder
4344

4445

45-
class Event(NamedTuple):
46+
@dataclass(frozen=True)
47+
class Event:
4648
"""An Event object represents the context of an event.
4749
4850
Events themselves are just a bundle of data. They must be emitted
4951
along an :class:`EventChannel` in order for other simulation components
5052
to respond to them.
5153
"""
5254

53-
# FIXME [MIC-5468]: fix index type hint for mypy
54-
index: pd.Index[int] # type: ignore[assignment]
55+
index: pd.Index[int]
5556
"""An index into the population table containing all simulants affected by this event."""
5657
user_data: dict[str, Any]
5758
"""Any additional data provided by the user about the event."""

0 commit comments

Comments
 (0)