-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Fix mypy errors in trainer code. #3135
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
Conversation
# repo: https://github.com/chriselion/mypy | ||
# rev: 3d0b6164a9487a6c5cf9d144110b86600fd85e25 | ||
# This is a fork with the assert disabled, although precommit has trouble installing it sometimes. | ||
rev: v0.761 |
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.
Tried bumping this to get the errors to show, but no luck. Removed the obsolete comment.
@@ -206,7 +206,7 @@ def update( | |||
return update_stats | |||
|
|||
def update_reward_signals( | |||
self, reward_signal_minibatches: Dict[str, Dict], num_sequences: int | |||
self, reward_signal_minibatches: Mapping[str, Dict], num_sequences: int |
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.
This was getting Dict[str, AgentBuffer] passed to it, which causes the helpful errors:
ml-agents/mlagents/trainers/sac/trainer.py:322: note: "Dict" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance
ml-agents/mlagents/trainers/sac/trainer.py:322: note: Consider using "Mapping" instead, which is covariant in the value type
@@ -70,7 +70,7 @@ def __init__( | |||
self.load = load | |||
self.multi_gpu = multi_gpu | |||
self.seed = seed | |||
self.policy: TFPolicy = None | |||
self.policy: PPOPolicy = None # type: ignore |
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.
Ignore the error of setting this to None, since we'll always set it to an instance before using.
No description provided.