Commit a5c6685
authored
## Summary
- Resolve GitHub Code scanning alert #10 (unreachable code warning)
- Resolve GitHub Code scanning alert #21 (mixed import style warning)
- Refactor test functions to improve code structure and maintainability
## Test plan
- [x] All 478 tests pass
- [x] Code formatting and style checks pass (ruff format, ruff check)
- [x] Type checking passes (mypy)
- [x] REUSE compliance check passes
- [x] Build verification successful (wheel and sdist)
- [x] All pre-commit hooks pass
## Changes Made
### Alert #10: Unreachable Code Warning
- **File**: `tests/test_unified_exception_handling.py`
- **Issue**: CodeQL detected unreachable code at line 455, caused by
static analyzer not understanding pytest.raises context manager control
flow
- **Solution**: Refactored
`test_error_handling_with_existing_py7zz_errors` function into four
separate test functions:
- `test_file_not_found_error_raising`
- `test_compression_error_raising`
- `test_extraction_error_raising`
- `test_existing_py7zz_errors_inheritance`
- **Benefits**: Eliminates CodeQL warning, improves test readability and
structure, follows "one test, one concern" best practice
### Alert #21: Mixed Import Style Warning
- **File**: `tests/test_pypi_version_validation.py`
- **Issue**: Mixed usage of `import py7zz` and `from py7zz.version
import ...` causing code style inconsistency
- **Solution**: Removed `from py7zz.version import ...` statement and
consistently use `py7zz.version.*` format
- **Benefits**: Consistent code style, clearer function origins, follows
Python best practices
## Technical Details
- All existing functionality preserved during refactoring
- Test coverage remains unchanged
- Full backward compatibility maintained
- Follows project code style conventions
## Verification
Complete CI simulation passed, including:
- Quick checks (format, lint, type checking)
- REUSE compliance verification
- Build verification (wheel + sdist)
- Comprehensive test suite (478 tests)
- All pre-commit hooks
These fixes will automatically resolve the corresponding security alerts
in the next CodeQL scan.
File tree
3 files changed
+14
-19
lines changed- scripts
- tests
3 files changed
+14
-19
lines changedFile mode changed.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 268 | + | |
278 | 269 | | |
279 | 270 | | |
280 | 271 | | |
281 | 272 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
287 | 278 | | |
288 | 279 | | |
289 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
450 | | - | |
451 | | - | |
| 449 | + | |
| 450 | + | |
452 | 451 | | |
453 | 452 | | |
454 | 453 | | |
| 454 | + | |
| 455 | + | |
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| 459 | + | |
| 460 | + | |
458 | 461 | | |
459 | 462 | | |
460 | 463 | | |
461 | | - | |
| 464 | + | |
| 465 | + | |
462 | 466 | | |
463 | 467 | | |
464 | 468 | | |
| |||
0 commit comments