-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[MLA-427] add pyupgrade to pre-commit and run #4239
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,13 @@ repos: | |
| # flake8-tidy-imports is used for banned-modules, not actually tidying | ||
| additional_dependencies: [flake8-comprehensions==3.2.2, flake8-tidy-imports==4.1.0, flake8-bugbear==20.1.4] | ||
|
|
||
| - repo: https://github.com/asottile/pyupgrade | ||
| rev: v2.7.0 | ||
| hooks: | ||
| - id: pyupgrade | ||
| args: [--py3-plus] | ||
| exclude: .*barracuda.py | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't want to run this on the barracuda scripts (similar to how we don't run pylint on them). |
||
|
|
||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v2.5.0 | ||
| hooks: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ def run(self): | |
| tag = os.getenv("CIRCLE_TAG") | ||
|
|
||
| if tag != EXPECTED_TAG: | ||
| info = "Git tag: {0} does not match the expected tag of this app: {1}".format( | ||
| info = "Git tag: {} does not match the expected tag of this app: {}".format( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we convert this to an actual f-string?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was saving that for the next PR. Adding |
||
| tag, EXPECTED_TAG | ||
| ) | ||
| sys.exit(info) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -326,8 +326,8 @@ def behavior_specs(self) -> MappingType[str, BehaviorSpec]: | |
| def _assert_behavior_exists(self, behavior_name: str) -> None: | ||
| if behavior_name not in self._env_specs: | ||
| raise UnityActionException( | ||
| "The group {0} does not correspond to an existing agent group " | ||
| "in the environment".format(behavior_name) | ||
| f"The group {behavior_name} does not correspond to an existing " | ||
| f"agent group in the environment" | ||
| ) | ||
|
|
||
| def set_actions(self, behavior_name: BehaviorName, action: np.ndarray) -> None: | ||
|
|
@@ -339,9 +339,9 @@ def set_actions(self, behavior_name: BehaviorName, action: np.ndarray) -> None: | |
| expected_shape = (len(self._env_state[behavior_name][0]), spec.action_size) | ||
| if action.shape != expected_shape: | ||
| raise UnityActionException( | ||
| "The behavior {0} needs an input of dimension {1} for " | ||
| "(<number of agents>, <action size>) but received input of " | ||
| "dimension {2}".format(behavior_name, expected_shape, action.shape) | ||
| f"The behavior {behavior_name} needs an input of dimension " | ||
| f"{expected_shape} for (<number of agents>, <action size>) but " | ||
| f"received input of dimension {action.shape}" | ||
| ) | ||
| if action.dtype != expected_type: | ||
| action = action.astype(expected_type) | ||
|
|
@@ -357,10 +357,9 @@ def set_action_for_agent( | |
| expected_shape = (spec.action_size,) | ||
| if action.shape != expected_shape: | ||
| raise UnityActionException( | ||
| f"The Agent {0} with BehaviorName {1} needs an input of dimension " | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This combination of an f-string with numbered .format() exposed a bug in pyupgrade: asottile/pyupgrade#329 |
||
| f"{2} but received input of dimension {3}".format( | ||
| agent_id, behavior_name, expected_shape, action.shape | ||
| ) | ||
| f"The Agent {agent_id} with BehaviorName {behavior_name} needs " | ||
| f"an input of dimension {expected_shape} but received input of " | ||
| f"dimension {action.shape}" | ||
| ) | ||
| expected_type = np.float32 if spec.is_action_continuous() else np.int32 | ||
| if action.dtype != expected_type: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| EPSILON = 1e-7 | ||
|
|
||
|
|
||
| class GAILModel(object): | ||
| class GAILModel: | ||
| def __init__( | ||
| self, | ||
| policy: TFPolicy, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| from __future__ import print_function | ||
| import sys | ||
| import os | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.