-
Notifications
You must be signed in to change notification settings - Fork 883
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
type annotations: Replace Union[a, b] with a | b, Optional[a] with a | None #1341 #2003
Conversation
Performance benchmarks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from two minor things, looks good!
Now we just have to wait until we drop Python 3.9 support. I think that will happen after the Mesa 2.3 release, which will probably release in February or March. If you want, you can help with that when the time comes.
mesa/time.py
Outdated
# Mypy; for the `|` operator purpose | ||
# Remove this __future__ import once the oldest supported Python is 3.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two lines can also be removed
What's blocking us from doing it for Mesa 2.3? See also #1756 (comment). |
Hi, is there any way I can contribute in any similar issue. |
I think improving the example models in Mesa-examples and adding new ones is now the most useful. Especially if you include new features like the AgentSet or PropertyLayer. |
Adding more Mypy annotations would also be useful. |
@Aryan1Mahahjan here are several type checking errors for mesa/agent.py
are you interested in looking to fixing it? You should start with opening a PR with small changes first, so that it can get merged earlier. |
Yes I am interested I will look into it. |
You do type checking by installing Mypy and running |
Virtually all these changes have been implemented by now, so I am closing this PR. |
Solving the issue of replacing Union[a, b] with a | b and Optional[a] with a | None in type annotations:
Replacing Union[a, b] with a | b:
Improves readability and clarity of type hints.
Makes it easier to understand what types are allowed for a variable or function parameter.
Provides better type checking by the static type checker.
It may CI issuse in build / build (ubuntu, 3.9) (pull_request)
Aryan1Mahajahn