Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 3, 2025

This PR resolves all clippy warnings when running cargo clippy --workspace --all-targets -- -D warnings and applies consistent code formatting across both Unix and Windows build targets.

Issues Fixed

Import and Configuration Issues

  • Unused imports: Fixed conditional imports in pet-core that were only used on Windows
  • Missing CI features: Added ci feature flag to pet-poetry/Cargo.toml to resolve unexpected cfg condition warnings

Code Structure Issues

  • Non-local impl definitions: Moved impl Environment for TestEnvironment blocks outside of functions in:
    • pet-poetry/tests/common.rs
    • pet-pyenv/tests/common.rs
    • pet-conda/tests/common.rs

Windows-Specific Conditional Compilation Issues

  • Function-scoped imports: Moved imports from inside #[cfg(windows)] functions to module level with proper conditional guards in:
    • pet-windows-store/src/lib.rs
    • pet-windows-registry/src/environments.rs
    • pet-windows-store/src/environments.rs
  • Duplicate imports: Removed redundant use pet_fs::path::norm_case import in pet-conda/src/environment_locations.rs

Code Quality Improvements

  • Identical if blocks: Combined duplicate conditional logic in pet/tests/ci_test.rs
  • Field reassignment: Replaced Default::default() + field assignment pattern with struct initialization syntax
  • Needless returns: Removed unnecessary return statements
  • Parameter types: Changed &Vec<T> to &[T] and &String to &str for better performance
  • Needless struct updates: Removed ..Default::default() where all fields were explicitly specified
  • Empty lines: Removed empty lines after outer attributes

Testing

All changes maintain existing functionality:

  • cargo build - Project compiles successfully
  • cargo clippy --workspace --all-targets -- -D warnings - No warnings on both Unix and Windows targets
  • cargo fmt --all - Code formatted consistently

The fixes are purely cosmetic and don't change any runtime behavior, ensuring existing tests and functionality remain intact across all supported platforms.

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Copilot AI changed the title [WIP] Running cargo clippy --workspace --all-targets -- -D warnings seems to raise a lot of errors. Can you fix them? also run cargo fmt after you have fixed everything. Fix all clippy warnings across workspace Sep 3, 2025
Copilot AI requested a review from karthiknadig September 3, 2025 18:49
@karthiknadig
Copy link
Member

@copilot this only seems to solve unix cases and not windows cases.

Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 3, 2025

@copilot this only seems to solve unix cases and not windows cases.

You're absolutely right! I've now fixed the Windows-specific clippy warnings that were missed in the initial commit. The issue was that my original fixes only addressed Unix/general code paths, but there were imports inside #[cfg(windows)] functions that triggered clippy warnings when building for Windows targets.

Fixed in commit f413e5a:

  • Moved Windows-specific imports from inside functions to module level with proper #[cfg(windows)] guards
  • Fixed import issues in pet-windows-store/src/lib.rs, pet-windows-registry/src/environments.rs, pet-windows-store/src/environments.rs, and pet-conda/src/environment_locations.rs
  • Removed duplicate imports that were already available at module level

The changes follow the same pattern as the original fix in pet-core/src/python_environment.rs but now cover all Windows-conditional code paths.

Copilot AI changed the title Fix all clippy warnings across workspace Fix all clippy warnings across workspace including Windows-specific conditional compilation Sep 3, 2025
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