Skip to content

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

Merged
merged 12 commits into from
Dec 30, 2019
Merged

Fix mypy errors in trainer code. #3135

merged 12 commits into from
Dec 30, 2019

Conversation

chriselion
Copy link
Contributor

No description provided.

# 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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@chriselion chriselion requested a review from andrewcoh December 30, 2019 21:51
@chriselion chriselion merged commit c806015 into master Dec 30, 2019
@delete-merged-branch delete-merged-branch bot deleted the develop-fix-mypy-trainer branch December 30, 2019 23:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants