Skip to content

Add and refine type annotations in mesa.time.event#3412

Closed
Tushar1733 wants to merge 5 commits intomesa:mainfrom
Tushar1733:main
Closed

Add and refine type annotations in mesa.time.event#3412
Tushar1733 wants to merge 5 commits intomesa:mainfrom
Tushar1733:main

Conversation

@Tushar1733
Copy link
Copy Markdown
Contributor

This PR improves type annotations in the mesa.time.event module.

Changes include:

  • Adding explicit return types for __getstate__, __setstate__, and other methods
  • Refining Callable annotations to Callable[..., Any]
  • Ensuring consistency across Event and EventGenerator

No functional changes were made.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.0% [-0.7%, +0.8%] 🔵 -0.9% [-1.2%, -0.6%]
BoltzmannWealth large 🔵 +0.3% [-0.2%, +0.7%] 🔵 -0.3% [-0.9%, +0.3%]
Schelling small 🔵 +0.4% [+0.1%, +0.7%] 🔵 -0.9% [-1.0%, -0.7%]
Schelling large 🔵 +1.0% [+0.5%, +1.6%] 🔵 +1.2% [-0.2%, +2.4%]
WolfSheep small 🔵 -0.2% [-0.8%, +0.3%] 🔵 -0.1% [-0.3%, +0.0%]
WolfSheep large 🔵 +0.9% [-0.0%, +2.0%] 🔵 +2.3% [+1.5%, +3.4%]
BoidFlockers small 🔵 +1.8% [+0.6%, +3.0%] 🔵 +0.8% [+0.7%, +1.0%]
BoidFlockers large 🔵 +1.1% [+0.2%, +1.9%] 🔵 +0.1% [-0.0%, +0.2%]

self,
time: int | float,
function: Callable,
function: Callable[..., Any],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you explain how to read this typing information.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Callable[..., Any] means the function can take any arguments and return any type. Since event callbacks may have different signatures, this keeps the typing flexible while being more explicit than a plain Callable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove the changes to agentset.py. They are not part of this PR given your description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback.
I noticed that the PR was created from main, which included unintended changes (e.g., in agentset.py).
I’ll create a clean branch with only the event module changes and open a new PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants