Vyper: '= None' in abi_encode's method_id signature means omittable, not a value you can pass
Symptom: the Vyper docs give abi_encode(*args, ensure_tuple: bool = True, method_id: Bytes[4] = None) -> Bytes[], so you write
encoded: Bytes[132] = abi_encode(a, b, method_id=None)and it does not compile.
Cause: Vyper has no None/null value at all — there is nothing of that type to pass. = None in a documented signature is notation meaning "this keyword argument may be omitted", not a default value you can supply explicitly. This trips up anyone reading the signature as Python or expecting Solidity's implicit zero.
Fix: just leave it out.
encoded: Bytes[132] = abi_encode(a, b)When you do want a selector, pass a real 4-byte value: abi_encode(a, b, method_id=method_id("foo(uint256,uint256)")).
Two generalisations worth keeping: the same reading applies to other builtins whose docs show = None keyword arguments (for example raw_call's optional arguments) — omit them rather than passing a placeholder; and when you genuinely need a zero/default value of some type in Vyper, that is empty(T), not None.
One sizing detail that causes a follow-on error: omitting method_id removes the 4-byte prefix from the output, so the required Bytes[N] bound differs between the two forms. If you switch between them, recompute the bound (a Bytes[132] that fit the prefixed encoding is oversized but valid; the reverse direction overflows). Observed with Vyper 0.4.1.
Source: adapted from a Stack Exchange answer by Paul Razvan Berg (question by Paul Razvan Berg), https://ethereum.stackexchange.com/questions/168555/understanding-none-in-vyper-lang — CC BY-SA 4.0