TP0302
Warning: warning: a library’s or extension module’s definition can’t be exported (M22, M25)
Messages
Section titled “Messages”'<f>' is not exported: <reason>, where<reason>isits type parameter '<T>' has a bound'<T>?' has no .NET generic formit uses '<g>', which isn't a .NET genericit uses '<C>', which isn't exportedit has its module's name(M22)'<T>' can't be passed to Pythonit's generic(M25)it's used as the protocol '<P>'(M40)'<T>' can't be passed to Cit's asyncit has '*args' or '**kwargs'it has keyword-only parameters(a native library) (M45), with helprename it '_<f>' to keep it private
Example
Section titled “Example”From the golden case tests/cases/m40/tp0302_protocol_library.tpn:
# In a library, a generic class used as a protocol type is compiled per instantiation, so it is not exported (SPEC §14.2).class Getter[T](Protocol): def get(self) -> T: ...
class Bag[T]: value: T
def __init__(self, value: T): self.value = value
def get(self) -> T: return self.value
def read(g: Getter[int]) -> int: return g.get()
def demo() -> int: return read(Bag(5))The compiler reports:
tp0302_protocol_library.tpn:5:7: warning TP0302: 'Bag' is not exported: it's used as the protocol 'Getter[int]' help: rename it '_Bag' to keep it privateThe specification lists every code.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.