amaranth
amaranth copied to clipboard
Pyright errors on `m.[If/Elif/Else]`: No `__enter__` or `__exit__`
Hello! Reporting a Pyright error with Module.If/Else/Elif. This is reproducible with the following example:
from amaranth import *
class Thing(Elaboratable):
def __init__(self) -> None:
self.a = Signal(Shape(1))
self.b = Signal(unsigned(8))
def elaborate(self, platform) -> Module:
m = Module()
with m.If(self.a == 0):
m.d.sync += self.b.eq(12)
with m.Elif(self.a == 1):
m.d.sync += self.b.eq(34)
with m.Else():
m.d.sync += self.a.eq(0)
return m
...which yields the following:
Using:
pyright 1.1.344amaranth 0.4.5python 3.12.2
Note that:
- The above example does emit valid verilog- the lack of
__enter__and__exit__here just triggers type errors with Pyright. - I haven't observed this happening with
Switch/Caseor others.
That's expected. Amaranth isn't currently type-checker-clean for downstream code and we don't yet have that scheduled on our roadmap.