Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add machine-readable output format, and test #3473

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ferdnyc
Copy link

@ferdnyc ferdnyc commented Jun 26, 2024

Passing --machine-readable / -m to codespell, or setting machine-readable = true in the config file, will enable an output format designed to be more easily parsed, and containing the start column of the match (usually not output).

Inspired by the eslint -f compact format (which is no longer part of standard eslint), but with an added @ at the start of each line. (Useful when combined with context or summary options, to parse only the lines containing error data).

Intended primarily for actions-codespell and other wrapper scripts.

A new test, test_machine_readable, is added to test_basic.py to verify basic functionality of the new option.

The output, specifically, takes the form:

@./path/file.xtn: line 1, col 1, wrongword => rightword (reason if defined)

Line and column numbers are 1-based (i + 1 and match.start() + 1 in the code, respectively).

Passing `--machine-readable` / `-m` to codespell, or setting
`machine-readable = true` in the config file, will enable an output
format designed to be more easily parsed, and containing the start
column of the match (usually not output).

Inspired by the `eslint -f compact` format (which is no longer
part of standard eslint), but with an added `@` at the start of
each line. (Useful when combined with context or summary options,
to parse only the lines containing error data).

Intended primarily for actions-codespell and other wrapper scripts.
@ferdnyc
Copy link
Author

ferdnyc commented Jun 26, 2024

Hrm. The failure is due to ruff complaining:

Error: codespell_lib/_codespell.py:843:5: PLR0912 Too many branches (47 > 46)
Error: codespell_lib/_codespell.py:843:5: PLR0915 Too many statements (123 > 119)

...because I expanded parse_file().

The fact that my changes pushed it just above the limits make me think that every time that function is extended, it exceeds the limits, so they get raised until it's just barely passing again.

That seems like no way to live, but if that's how it's done I guess I can just bump them again...

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

Successfully merging this pull request may close these issues.

2 participants