You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NamedTuple should not satisfy Protocol with mutable fields #5293
OK, the solution is super-simple here. Since named tuple variables are "artificial" (auto-generated), and therefore are always created directly as a Var with is_property set to True, they are not identified as immutable by protocol check (it looks for a property decorator).
So it would be just one line fix in subtypes.get_member_flags, we need to add a check for v.is_property in this code:
# just a variable
if isinstance(v, Var):
flags = {IS_SETTABLE}
Activity
ilevkivskyi commentedon Jun 29, 2018
OK, the solution is super-simple here. Since named tuple variables are "artificial" (auto-generated), and therefore are always created directly as a
Varwithis_propertyset toTrue, they are not identified as immutable by protocol check (it looks for apropertydecorator).So it would be just one line fix in
subtypes.get_member_flags, we need to add a check forv.is_propertyin this code:Would you like to make a PR?
pnachum commentedon Jun 29, 2018
I'll leave that to people smarter than me 😄.
Make NamedTuple attributes read-only (#5299)