Commit cc49221
Convert MODE constants to IntEnum
Convert the MODE_* constants to an IntEnum class for better type
safety, IDE support, and more descriptive string representations.
Changes:
- Created Mode IntEnum with AUTO, MMAP_EXT, MMAP, FILE, MEMORY, FD members
- Added comprehensive documentation for the Mode class and each member
- Maintained backward compatibility by exporting old-style constants
(MODE_AUTO, MODE_FILE, etc.) as aliases to enum members
- Added __all__ to explicitly define the public API
Benefits:
- Better IDE autocomplete and type hints
- Descriptive repr: <Mode.FILE: 4> instead of just 4
- Access to .name and .value attributes
- Full backward compatibility (IntEnum is int-compatible)
- Modern Python 3.10+ idiom
- Inline documentation for each mode visible in source and IDEs
Backward compatibility: All existing code continues to work unchanged.
Both Mode.FILE and MODE_FILE can be used interchangeably, and all
numeric comparisons work as before since IntEnum is int-compatible.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 2a2f6d4 commit cc49221
2 files changed
+52
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
0 commit comments