Skip to content

Commit 107b4fa

Browse files
committed
Fix improper field access of HTTPError exception
1 parent 9b50e8d commit 107b4fa

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- uses: actions/setup-python@v2
1414
with:
15-
python-version: 3.7.x
15+
python-version: 3.9.x
1616
- uses: actions/setup-ruby@v1
1717
with:
1818
ruby-version: '2.6'
1919
- uses: actions/setup-dotnet@v1
2020
with:
21-
dotnet-version: '3.1.x'
21+
dotnet-version: '5.0.x'
2222
- uses: pre-commit/action@v2.0.0
2323

2424
markdown-link-check:

.pre-commit-config.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
minimum_pre_commit_version: 2.14.1
12
repos:
23
- repo: https://github.com/python/black
34
rev: 19.3b0
@@ -20,14 +21,14 @@ repos:
2021
- id: mypy
2122
name: mypy-ml-agents-envs
2223
files: "ml-agents-envs/.*"
23-
# Exclude protobuf files and don't follow them when imported
24-
exclude: >
25-
(?x)^(
26-
.*_pb2.py|
27-
.*_pb2.pyi|
28-
.*_pb2_grpc.py
29-
)$
30-
args: [--ignore-missing-imports, --disallow-incomplete-defs]
24+
args:
25+
- --ignore-missing-imports
26+
- --disallow-incomplete-defs
27+
- --disable-error-code=override
28+
- --disable-error-code=attr-defined # TODO: Move annotation into files
29+
- --disable-error-code=valid-type # https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
30+
- --exclude="ml-agents-envs/mlagents_envs/communicator_objects/*_pb2.py"
31+
- --show-error-codes
3132
additional_dependencies: [types-PyYAML, types-setuptools, types-protobuf, types-attrs]
3233
- id: mypy
3334
name: mypy-gym-unity
@@ -91,11 +92,11 @@ repos:
9192
types: [markdown]
9293
exclude: ".*localized.*"
9394

94-
- repo: https://github.com/dotnet/format
95-
rev: "7e343070a0355c86f72bdee226b5e19ffcbac931" # TODO - update to a tagged version when one that includes the hook is ready.
96-
hooks:
97-
- id: dotnet-format
98-
args: [--folder, --include]
95+
# - repo: https://github.com/dotnet/format
96+
# rev: v5.1.225507
97+
# hooks:
98+
# - id: dotnet-format
99+
# args: [--folder, --include]
99100

100101
# "Local" hooks, see https://pre-commit.com/#repository-local-hooks
101102
- repo: local

ml-agents-envs/mlagents_envs/registry/binary_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def download_and_extract_zip(url: str, name: str) -> None:
137137
try:
138138
request = urllib.request.urlopen(url, timeout=30)
139139
except urllib.error.HTTPError as e: # type: ignore
140-
e.msg += " " + url
140+
logger.warning(f"Failed to fetch resource at URL: {url}, reason: {e.reason}")
141141
raise
142142
zip_size = int(request.headers["content-length"])
143143
zip_file_path = os.path.join(zip_dir, str(uuid.uuid4()) + ".zip")
@@ -193,7 +193,9 @@ def load_remote_manifest(url: str) -> Dict[str, Any]:
193193
try:
194194
request = urllib.request.urlopen(url, timeout=30)
195195
except urllib.error.HTTPError as e: # type: ignore
196-
e.msg += " " + url
196+
logger.warning(
197+
f"Failed to fetch manifest resource at URL: {url}, reason: {e.reason}"
198+
)
197199
raise
198200
manifest_path = os.path.join(tmp_dir, str(uuid.uuid4()) + ".yaml")
199201
with open(manifest_path, "wb") as manifest:

0 commit comments

Comments
 (0)