Feature or enhancement
Proposal:
Today, ast.unparse(ast.Set(elts=[])) renders as {*()}, because Python has no dedicated empty-set literal. Without AST canonicalization on parse, reparsing that output produces a Set containing Starred(Tuple([])) instead of an empty Set, so the AST does not round-trip cleanly.
Regardless of decision on PEP 802 this may provide a win for anyone who has already adopted this {*()} idiom.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Various contributors to the discussion on PEP 802: https://discuss.python.org/t/pep-802-display-syntax-for-the-empty-set/101676
Linked PRs
Feature or enhancement
Proposal:
Today,
ast.unparse(ast.Set(elts=[]))renders as{*()}, because Python has no dedicated empty-set literal. Without AST canonicalization on parse, reparsing that output produces aSetcontainingStarred(Tuple([]))instead of an emptySet, so the AST does not round-trip cleanly.Regardless of decision on PEP 802 this may provide a win for anyone who has already adopted this
{*()}idiom.Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Various contributors to the discussion on PEP 802: https://discuss.python.org/t/pep-802-display-syntax-for-the-empty-set/101676
Linked PRs