Skip to content

Conversation

@Renkai
Copy link
Contributor

@Renkai Renkai commented Oct 3, 2025

Part of: #19016, for lint.rs

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Renkai added 4 commits October 3, 2025 09:17
- Keep insta::with_settings filters as they are still needed
- The filters replace temporary directory paths in warning messages
- All refactored functions now pass: top_level_options, lint_options, mixed_levels, precedence
You were correct - RuffTestFixture functions don't need the tempdir filters
because the warning messages show clean filenames (ruff.toml) rather than
full temporary directory paths.

- Removed insta::with_settings! wrappers
- Use raw assert_cmd_snapshot! calls
- Removed unused tempdir_filter import
- All tests pass: top_level_options, lint_options, mixed_levels, precedence
@MichaReiser
Copy link
Member

Thanks for working on this. Yes, this is what I had in mind.

Renkai added 18 commits October 4, 2025 09:08
…uffTestFixture

- exclude: Uses RuffTestFixture.new() and write_file() for multiple files
- deduplicate_directory_and_explicit_file: Simple refactoring with write_file()
- Both functions now use clean assert_cmd_snapshot! calls without filters
- Tests pass with identical behavior
…stFixture

- exclude_stdin: Uses RuffTestFixture.with_file() for stdin-based testing
- line_too_long_width_override: Another stdin-based function refactoring
- Both functions now use clean assert_cmd_snapshot! calls without filters
- Tests pass with identical behavior after snapshot updates
@Renkai Renkai marked this pull request as ready for review October 4, 2025 03:14
@Renkai
Copy link
Contributor Author

Renkai commented Oct 4, 2025

Hi @MichaReiser , not sure why I can't modify the reviewers label, PTAL

@Renkai
Copy link
Contributor Author

Renkai commented Oct 4, 2025

Can't help on modify the windows insta snapshots very well, because I don't own a windows computer

@Renkai
Copy link
Contributor Author

Renkai commented Oct 5, 2025

Can't help on modify the windows insta snapshots very well, because I don't own a windows computer

You can edit snapshots by hand. It's a bit pain but it should be okay if it's only that / is replaced with TMP/.

For the other changes. It looks like there's a missing filter somewhere where the base path isn't filtered out anymore.

I fixed the filter problem, but for some tests, windows and linux have different behavior, the linux tests expect ruff.toml but windows expect [TMP]/ruff.toml. I doubt the fs::relativize_path method does not work well in some cases for windows.

https://github.com/Renkai/ruff/blob/2d3458f242188f9a3cdda46ada0aefacafd7f406/crates/ruff_workspace/src/configuration.rs#L1605

@Renkai
Copy link
Contributor Author

Renkai commented Oct 5, 2025

In the new pattern, there are four functions have different behavior between windows and linux

  • line_too_long_width_override
  • mixed_levels
  • precedence
  • top_level_options
    I reverted them to the main branch version. It's most likely caused by fs::relativize_path can't work well in some cases, I recommend to create a new issue for them.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Nice. This is great. I only have a few questions around using dunce/dedent

//! The core concept is borrowed from ty/tests/cli/main.rs and can be extended
//! with more functionality from there in the future if needed.

#![allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the allow dead code and remove any unusede code instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current functions are actually all used, not sure why the clippy believe they are dead, add some unit tests to make sure they are used now.

Comment on lines 26 to 30
let normalized_path = if let Some(stripped) = path_str.strip_prefix(r"\\?\") {
stripped
} else {
path_str
};
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason why you aren't using dunce here (you can add it as a dev-only dependency)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice crate, I didn't know it exists before.

Comment on lines 37 to 38
// Always add optional UNC prefix to match both \\?\C:\... and C:\... patterns
// This ensures compatibility regardless of whether input or output contains UNC prefix
Copy link
Member

Choose a reason for hiding this comment

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

Rather than handling UNC paths here, I suggest to do the same as ty and strip any UNC prefix in new

Comment on lines 76 to 79
let project_dir = temp_dir
.path()
.canonicalize()
.context("Failed to canonicalize project path")?;
Copy link
Member

Choose a reason for hiding this comment

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

Let's strip the UNC prefix here using dunce (you can add it as a dev dependency)


Self::ensure_parent_directory(&file_path)?;

let content = content.trim_start_matches('\n');
Copy link
Member

Choose a reason for hiding this comment

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

Can we use dedent here instead of trimming start new lines only?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@Renkai Renkai requested a review from MichaReiser October 7, 2025 00:32
@MichaReiser MichaReiser added the testing Related to testing Ruff itself label Oct 7, 2025
@MichaReiser MichaReiser merged commit 76f8e5b into astral-sh:main Oct 7, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants