Skip to content

Commit ce725b0

Browse files
authored
Merge pull request #1685 from byuccl/pylint_args
Update pylint_check.py to check individual files
2 parents fe2c914 + 88ede15 commit ce725b0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

README.developers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ For large scale reformatting (should only be performed by VTR maintainers) the s
177177

178178
## Python Linting
179179

180-
Python files are automatically checked using `pylint` to ensure they follow established Python conventions. You can check an individual Python file by running `pylint <your_python_file>`, or check the entire repository by running `./dev/pylint_check.py`.
180+
Python files are automatically checked using `pylint` to ensure they follow established Python conventions. You can run `pylint` on the entire repository by running `./dev/pylint_check.py`. Certain files which were created before we adopted Python lint checking are grandfathered and are not checked. To check *all* files, provide the `--check_grandfathered` argument. You can also manually check individual files using `./dev/pylint_check.py <path_to_file1> <path_to_file2> ...`.
181181

182182
# Running Tests
183183

dev/pylint_check.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def expand_paths():
121121
if path.suffix.lower() != ".py":
122122
print(path, "does note have extension '.py'")
123123
sys.exit(-1)
124-
paths.append(path)
124+
paths.append(path.resolve())
125125

126126
# If path is a directory, search for .py files
127127
elif path.is_dir():
@@ -151,11 +151,22 @@ def main():
151151
action="store_true",
152152
help="Also check grandfathered files for lint errors.",
153153
)
154+
parser.add_argument("files", nargs="*", help="List of files to check using pylint.")
154155
args = parser.parse_args()
155156

156-
# Expand all paths
157-
paths = expand_paths()
158-
print(TermColor.BLUE + "Linting", len(paths), "python files.", TermColor.END)
157+
# Check if we are doing all files, or user-provided list
158+
if args.files:
159+
# Check that all files exist, and build pathlib objects
160+
paths = []
161+
for file in args.files:
162+
f_path = pathlib.Path(file).resolve()
163+
if not f_path.is_file():
164+
error(f_path, "does not exist")
165+
paths.append(f_path)
166+
else:
167+
# Expand all paths
168+
paths = expand_paths()
169+
print(TermColor.BLUE + "Linting", len(paths), "python file(s).", TermColor.END)
159170

160171
# Lint files
161172
num_error_files = 0

0 commit comments

Comments
 (0)