Skip to content

Prevent --update-functional-output from deleting or overwriting fallback versioned output files for other Python versions.#10950

Open
mchris86 wants to merge 2 commits intopylint-dev:mainfrom
mchris86:main
Open

Prevent --update-functional-output from deleting or overwriting fallback versioned output files for other Python versions.#10950
mchris86 wants to merge 2 commits intopylint-dev:mainfrom
mchris86:main

Conversation

@mchris86
Copy link
Copy Markdown

@mchris86 mchris86 commented Apr 1, 2026

Type of Changes

Type
🐛 Bug fix

Description

Closes #10844

Fix --update-functional-output so it does not delete or overwrite fallback versioned expected-output files.

When Pylint runs on a newer Python version (e.g. 3.14) and no matching output file exists (like .314.txt), it falls back to an older version (e.g. .313.txt). The problem is that --update-functional-output would then modify that fallback file, when it shouldn't.

The fix adds a way to detect when the expected output file is a fallback. In such cases, the update logic skips deleting/overwriting the file.

Regression tests are added to cover both cases:

  • fallback versioned output is not deleted
  • fallback versioned output is not overwritten

Testing

pytest tests/testutils/test_lint_module_output_update.py -v

Before this fix, the new tests fail because the fallback file is modified. After applying the fix, all tests pass.

@Pierre-Sassoulas
Copy link
Copy Markdown
Member

Thank you for working on pylint; I was planning on using pytest-remaster for the functional tests (there's an annoying number of edge cases and test to do to make it right and pylint main purpose is not to create a testing framework). I can push my work in progress if it helps

@mchris86
Copy link
Copy Markdown
Author

mchris86 commented Apr 1, 2026

Thanks for the context!
I would definitely be interested in seeing your work in progress.

@Pierre-Sassoulas
Copy link
Copy Markdown
Member

Pushed in https://github.com/pylint-dev/pylint/tree/pytest-remaster, it's pretty raw still

@mchris86
Copy link
Copy Markdown
Author

mchris86 commented Apr 2, 2026

Thanks, I looked into the pytest-remaster branch and was able to reproduce the issue there as well.

It looks like test_file.expected_output is being used both to select the comparison target and the update target.

In the remaster version, that shows up here:

golden_master.check(
    lint_test.serialize_output(actual_output), test_file.expected_output 
)

If expected_output is a fallback like .313.txt while running on 3.14, remaster still updates that file.

In my attempt I handled this by detecting fallback outputs and skipping updates in that case. I'd be happy to help handle this in the remaster approach if that would be useful.

@Pierre-Sassoulas
Copy link
Copy Markdown
Member

Sure, a new look on the pytest-remaster implementation would be great !

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_functional.py --update-functional-output deletes files for other Python versions

2 participants