Skip to content

Commit a137732

Browse files
author
Vincent Moens
committed
Update
[ghstack-poisoned]
1 parent d7a6812 commit a137732

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+256
-164
lines changed

check_future_imports.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
import os
7+
8+
9+
def find_files_without_future_annotations(directory):
10+
"""Finds Python files that do not contain 'from __future__ import annotations'."""
11+
files_without_annotations = []
12+
13+
for root, _, files in os.walk(directory):
14+
for file in files:
15+
if file.endswith(".py"):
16+
file_path = os.path.join(root, file)
17+
with open(file_path, encoding="utf-8") as f:
18+
content = f.read()
19+
if "from __future__ import annotations" not in content:
20+
files_without_annotations.append(file_path)
21+
22+
return files_without_annotations
23+
24+
25+
if __name__ == "__main__":
26+
repo_directory = "." # Change this to your repository's root directory
27+
files = find_files_without_future_annotations(repo_directory)
28+
if files:
29+
print("Files without 'from __future__ import annotations':")
30+
for file in files:
31+
print(file)
32+
else:
33+
print("All files contain 'from __future__ import annotations'.")

test/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
5+
from __future__ import annotations
6+
57
import functools
68
import os
79
import sys

test/test_exploration.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,8 @@ def test_nested(
379379
)
380380

381381
action_spec = env.action_spec
382-
d_act = action_spec.shape[-1]
382+
action_spec.shape[-1]
383383

384-
nn.LazyLinear(d_act).to(device)
385384
policy = TensorDictModule(
386385
CountingEnvCountModule(action_spec=action_spec),
387386
in_keys=[("data", "states") if nested_obs_action else "observation"],

test/test_transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,7 @@ def make_env():
47854785
)
47864786
return env
47874787

4788-
SerialEnv(2, make_env)
4788+
SerialEnv(2, make_env).check_env_specs()
47894789

47904790
def test_parallel_trans_env_check(self, maybe_fork_ParallelEnv):
47914791
def make_env():

torchrl/_extension.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
5+
from __future__ import annotations
56

67
import importlib.util
78
import warnings

torchrl/collectors/distributed/default_configs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
from __future__ import annotations
6+
17
import os
28

39
TCP_PORT = os.environ.get("TCP_PORT", "10003")

torchrl/collectors/distributed/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
from __future__ import annotations
7+
18
import subprocess
29
import time
310

torchrl/data/datasets/d4rl_infos.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
5+
from __future__ import annotations
56

67
D4RL_DATASETS = {
78
"maze2d-open-v0": "http://rail.eecs.berkeley.edu/datasets/offline_rl/maze2d/maze2d-open-sparse.hdf5",

torchrl/data/datasets/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
5+
from __future__ import annotations
6+
57
import os
68

79

torchrl/envs/custom/pendulum.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
5+
from __future__ import annotations
6+
57
import numpy as np
68

79
import torch

0 commit comments

Comments
 (0)