Skip to content

Commit

Permalink
Also skip bin directory with ruff
Browse files Browse the repository at this point in the history
Need this until ruff adds support for .gitignore outside of
a git repo.
  • Loading branch information
timj committed Jul 20, 2023
1 parent 1f1c806 commit 27cf150
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions python/lsst/sconsUtils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def runPythonLinter(self):
linter: str | None = None
root = SCons.Script.Dir("#").abspath

# Never want linters to look in this directory.
exclude_dirs = ["tests/.tests"]

pyproject = os.path.join(root, "pyproject.toml")
if os.path.exists(pyproject):
try:
Expand All @@ -331,6 +334,10 @@ def runPythonLinter(self):
if "tool" in parsed and "ruff" in parsed["tool"]:
linter = "ruff"

# Ruff can complain about #noqa in shebang line
# added by sconsUtils to bin/ scripts. Need to ignore.
exclude_dirs.append("bin")

if linter is None:
flake8_cfg = os.path.join(root, "setup.cfg")
if os.path.exists(os.path.join(root, ".flake8")):
Expand Down Expand Up @@ -364,9 +371,8 @@ def runPythonLinter(self):
for path in glob.glob(os.path.join(self._tmpDir, "linter-*.log*")):
os.unlink(path)

# Always exclude the tests output directory. This should never be
# examined.
lint_options = "--extend-exclude=tests/.tests"
# Specify exclude directories.
lint_options = f"--extend-exclude={','.join(exclude_dirs)}"

cmd = f"""
@printf "%s\\n" 'Running python linter {linter}...';
Expand Down

0 comments on commit 27cf150

Please sign in to comment.