UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

49 lines (38 loc) • 1.09 kB
# No super() in TorchScript # Detects super() calls in TorchScript methods id: no-super-torchscript name: super Should Not Be Used in TorchScript Methods severity: error category: reliability defect_class: correctness inline_tier: blocking language: python message: "super() calls should not be used in TorchScript methods" description: | TorchScript does not support super() calls. Refactor to avoid inheritance or use composition instead for PyTorch JIT compatibility. ✅ FIX: Use composition or avoid TorchScript for this class query: | (call function: (identifier) @FUNC (#eq? @FUNC "super")) @CALL metavars: - FUNC - CALL post_filter: torchscript_super_call tags: - reliability - python - pytorch - torchscript - deployment examples: bad: | @torch.jit.script class MyModel(nn.Module): def forward(self, x): return super().forward(x) # BAD - super in TorchScript good: | class MyModel(nn.Module): def forward(self, x): # GOOD - no TorchScript decorator return super().forward(x) has_fix: false