Skip to content

Fix lint traceback for .cylc directories - #7351

Open
binggao1230 wants to merge 3 commits into
cylc:8.6.xfrom
binggao1230:fix-7344-lint-cylc-dir
Open

Fix lint traceback for .cylc directories#7351
binggao1230 wants to merge 3 commits into
cylc:8.6.xfrom
binggao1230:fix-7344-lint-cylc-dir

Conversation

@binggao1230

@binggao1230 binggao1230 commented Jun 18, 2026

Copy link
Copy Markdown

Fixes #7344.

This prevents cylc lint from raising tracebacks for the issue reproduction where an empty flow.cylc exists alongside a directory named *.cylc.

Changes:

  • Report matched non-files as lint errors instead of trying to open them.
  • Treat empty lint inputs as having no lines to check.
  • Add regression tests for empty files and .cylc directories.
  • Add my name to the contributor list per CONTRIBUTING.md.

Verification:

  • .venv/bin/python -m pytest tests/unit/scripts/test_lint.py
  • .venv/bin/python -m flake8 cylc/flow/scripts/lint.py tests/unit/scripts/test_lint.py
  • git diff --check
  • Manual reproduction with touch flow.cylc, mkdir another.cylc, and cylc lint --exit-zero

@oliver-sanders oliver-sanders added the bug Something is wrong :( label Jun 19, 2026
@oliver-sanders

Copy link
Copy Markdown
Member

Hi @gaoflow 👋, thanks for your interest in Cylc.

Comment thread cylc/flow/scripts/lint.py Outdated
modify: bool = False,
):
"""Check A Cylc File for Cylc 7 Config"""
if not file.is_file():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be safer to use if file.is_dir here as these files are sometimes symlinks.

@binggao1230

Copy link
Copy Markdown
Author

Thanks, good point. I changed the guard to only special-case directories with file.is_dir(), so file symlinks and other openable paths are not rejected up front.

Local verification:

  • .venv/bin/python -m pytest tests/unit/scripts/test_lint.py::test_check_cylc_file_reports_directory tests/unit/scripts/test_lint.py::test_check_cylc_file_empty -q -> 2 passed
  • .venv/bin/python -m pytest tests/unit/scripts/test_lint.py -q -> 140 passed
  • git diff --check -> passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is wrong :(

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants