Skip to content

Ensure --batch and --logfile are distinct files#1962

Merged
rolandwalker merged 1 commit into
mainfrom
RW/ensure-distinct-batch-logfile
Jun 24, 2026
Merged

Ensure --batch and --logfile are distinct files#1962
rolandwalker merged 1 commit into
mainfrom
RW/ensure-distinct-batch-logfile

Conversation

@rolandwalker

Copy link
Copy Markdown
Contributor

Description

Motivation: to avoid some kind of infinite loop, in which mycli reads from a file which is constantly being written to.

This is much more succinct than #1931 , which changed the argument type from a file to a string. In retrospect that change was a mistake.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Jun 23, 2026
Comment thread mycli/main.py Outdated
and cli_args.batch != '-'
and os.path.exists(cli_args.batch)
):
if os.stat(cli_args.batch) == os.stat(cli_args.logfile.name):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Recommended way of checking if two files are the same file is os.path.samefile. Looks like we use os.stat directly elsewhere so it matches, but would be worth at least using it for new stuff

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@scottnemes scottnemes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left one nit, but fine to merge either way

Motivation: to avoid some kind of infinite loop, in which mycli reads
from a file which is constantly being written to.
@rolandwalker rolandwalker force-pushed the RW/ensure-distinct-batch-logfile branch from f3da90e to 9533565 Compare June 24, 2026 09:49
@rolandwalker rolandwalker merged commit 852b168 into main Jun 24, 2026
11 checks passed
@rolandwalker rolandwalker deleted the RW/ensure-distinct-batch-logfile branch June 24, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants