Generated: 2025-11-14 Previous Errors: 1,362 Current Errors: 558 Errors Fixed: 804 (59% reduction)
✅ Phase 1: var-annotated, unused-ignore, name-match, truthy-function (64 errors) ✅ Phase 2: AFI/SAFI architectural fix ✅ Phase 3: no-any-return fixes ✅ Phase 4: Logger type errors ✅ Phase 5-11: Additional fixes across arg-type, union-attr, operator, etc.
| Error Type | Count | % of Total | Fixable | Priority |
|---|---|---|---|---|
| [override] | 158 | 28% | Yes | HIGH |
| [attr-defined] | 152 | 27% | Partial | Medium |
| [misc] | 140 | 25% | Partial | Medium |
| [assignment] | 107 | 19% | Yes | HIGH |
| [int] | 35 | 6% | Partial | Low |
| [str] | 33 | 6% | Partial | Low |
| [bytes] | 31 | 6% | Partial | Low |
| [unused-ignore] | 1 | 0% | Yes | Low |
| [bool] | 1 | 0% | Yes | Low |
Total: 558 errors (note: some lines have multiple errors)
| Errors | File | Primary Issue |
|---|---|---|
| 126 | bgp/message/update/attribute/community/extended/traffic.py | [override] unpack() signatures |
| 66 | bgp/message/update/nlri/flow.py | [misc] type inference |
| 42 | bgp/message/update/attribute/pmsi.py | [override] signatures |
| 42 | bgp/message/update/attribute/community/extended/rt.py | [override] signatures |
| 42 | bgp/message/update/attribute/community/extended/origin.py | [override] signatures |
| 34 | bgp/message/update/attribute/nexthop.py | [override] + [misc] |
| 23 | configuration/check.py | [attr-defined] |
| 23 | bgp/message/update/attribute/originatorid.py | [override] signatures |
| 22 | bgp/message/operational.py | [misc] type annotations |
| 20 | bgp/message/update/nlri/mup/nlri.py | [override] signatures |
Pattern: Subclass method signatures incompatible with base class
Most Common Issue: unpack() method signature mismatches in extended communities
# Base class (ExtendedCommunityBase):
@classmethod
def unpack(cls, data: bytes, direction: Optional[int] = ..., negotiated: Negotiated = ...) -> ExtendedCommunityBase
# Subclass (TrafficRate):
@staticmethod
def unpack(data: bytes) -> TrafficRate # ❌ Wrong: missing parameters, @staticmethod vs @classmethodFiles Affected:
- community/extended/traffic.py (60 errors across 21 classes × ~3 errors each)
- community/extended/rt.py (42 errors)
- community/extended/origin.py (42 errors)
- Other extended community types (~14 errors)
Fix Strategy:
- Make subclass
unpack()methods match base signature:@classmethod def unpack(cls, data: bytes, direction: Optional[int] = None, negotiated: Optional[Negotiated] = None) -> TrafficRate: # Implementation can ignore unused parameters return cls(...)
- Alternative: Refactor base class to use method overloading if parameters truly vary
Estimated Effort: 4-6 hours Estimated Reduction: ~158 errors
Pattern: Accessing attributes that don't exist or aren't typed
Common Issues:
- Platform-specific attributes (AF_NETLINK on macOS)
- Module import issues
- Missing type stubs
Examples:
# configuration/check.py - Missing module attributes
Module "exabgp.conf" has no attribute "Config"
# Platform-specific
Module "socket" has no attribute "AF_NETLINK" # Only on LinuxFix Strategy:
- Add
# type: ignore[attr-defined]for platform-specific code - Fix genuine import errors
- Create stub files for missing module attributes
- Add proper type annotations to dynamic attributes
Estimated Effort: 3-5 hours Estimated Reduction: ~50 errors (many are platform-specific, need ignores)
Pattern: Miscellaneous type issues including:
- Cannot infer type of lambda
- Complex union types
- Type narrowing issues
Examples:
# flow.py - Complex union types causing inference issues
value: Union[int, str, bytes, tuple]
# Downstream operations can't narrow the type properly
# reactor/loop.py - Lambda type inference
log.debug(lambda: 'message') # Cannot infer lambda typeFix Strategy:
- Add explicit type annotations to lambdas:
lambda: str = lambda: 'message' - Add type guards for complex unions:
isinstance()checks - Use
cast()where type system can't infer correctly - Some may need
# type: ignore[misc]if unavoidable
Estimated Effort: 6-8 hours Estimated Reduction: ~70 errors (many are fundamental design issues)
Pattern: Assigning incompatible types to variables
Common Issues:
- Assigning
Noneto non-Optional variables - Type mismatches in attribute assignments
- Return value type mismatches
Fix Strategy:
- Change type annotations to Optional where None is assigned
- Fix type mismatches by converting values
- Add proper type guards
Estimated Effort: 3-4 hours Estimated Reduction: ~107 errors
Pattern: Operations expecting compatible types but receiving literals
Examples:
value: int = "string" # [str]
data: bytes = 123 # [int]Fix Strategy:
- Review each case to determine if annotation or assignment is wrong
- Add proper type conversions where needed
Estimated Effort: 2-3 hours Estimated Reduction: ~99 errors
Target: Fix unpack() signature mismatches in extended community classes
Approach:
- Start with
community/extended/traffic.py(126 errors) - Fix base signature to match subclass needs OR
- Fix all subclass signatures to match base class
- Apply pattern to rt.py, origin.py, and others
Files to fix:
- traffic.py (21 classes)
- rt.py (7 classes)
- origin.py (7 classes)
- Other extended community files (5 classes)
Expected reduction: ~158 errors Estimated time: 4-6 hours Impact: 28% of remaining errors
Target: Fix type mismatches in variable assignments
Expected reduction: ~107 errors Estimated time: 3-4 hours Impact: 19% of remaining errors
Target: Fix or suppress attribute definition errors
Expected reduction: ~50-70 errors Estimated time: 3-5 hours Impact: 9-13% of remaining errors
Target: Add type annotations and guards for complex types
Expected reduction: ~70 errors Estimated time: 6-8 hours Impact: 13% of remaining errors
Current: 558 errors After Phase 12 (override): ~400 errors (-158) After Phase 13 (assignment): ~293 errors (-107) After Phase 14 (attr-defined): ~223 errors (-70) After Phase 15 (misc): ~153 errors (-70)
Total projected reduction: ~405 errors (73% of remaining) Final projected error count: ~153 errors (89% reduction from original 1,362)
- All fixes must maintain Python 3.8+ compatibility
- All fixes must pass: ruff, pytest, functional encoding tests
- Some errors are fundamental design issues and may need
# type: ignore - Consider creating a mypy baseline for truly unfixable errors
- Platform-specific errors (AF_NETLINK, etc.) should be marked with conditional type: ignore