-
Notifications
You must be signed in to change notification settings - Fork 3
Fix ImportError with conflicting clang-format packages and improve error handling #109
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
Conversation
@shenxianpeng 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.
I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## main #109 +/- ## =========================================== - Coverage 94.48% 83.33% -11.15% =========================================== Files 3 3 Lines 145 168 +23 =========================================== + Hits 137 140 +3 - Misses 8 28 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com>
Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com>
Quality Gate Passed Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Uh oh!
There was an error while loading. Please reload this page.
This PR resolves the
ImportError: cannot import name 'clang_format' from 'clang_format'issue that occurs when users have conflicting PyPI packages installed alongside cpp-linter-hooks.Root Cause
The error occurs when users have conflicting
clang-formatscripts from PyPI packages (likeclang-format==21.1.0) that use incompatible import structures. These conflicts often stem from previous installations of version 1.0.0, which included clang tools as direct dependencies, leaving behind conflicting scripts in user environments.Solution
1. Comprehensive Documentation
Added a detailed troubleshooting section to the README with three solution approaches:
pip uninstall clang-format clang-tidy clang-tools2. Intelligent Conflict Detection
Implemented smart conflict detection that:
clang-formatscripts that contain problematic importsCLANG_FORMAT_HOOK_DEBUG=1is set (no noise in normal usage)# Enable debug mode to see conflict warnings CLANG_FORMAT_HOOK_DEBUG=1 clang-format-hook --help3. Enhanced Error Handling
Improved error messages throughout the codebase:
FileNotFoundErrormessages with helpful hintsclang_format.pyandclang_tidy.py4. Version Consistency
Updated all README examples to consistently use the latest version
v1.1.1.Testing
clang-format-hookandclang-tidy-hookentry points, avoiding namespace conflicts entirelyThis solution maintains backward compatibility while providing users clear paths to resolve conflicts.
Fixes #108.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.