classification
Title: AST sum types is unidentifiable after ast.Constant became a base class
Type: Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, pablogsal, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-06-18 09:38 by BTaskaya, last changed 2020-06-26 18:11 by BTaskaya. This issue is now closed.

Messages (3)
msg371797 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-06-18 09:38
Previously (before ast.Constant became a base class for deprecated node classes), Sum types were identifiable with this rule;

len(node_class.__subclasses__()) > 0

Now, this is also valid for the ast.Constant itself because of ast.Str, ast.Num etc. bases it. The bad side is, it makes (complex) sum classes unidentifiable.
msg371850 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-19 08:08
Where they were identifable in such way? It is incorrect way, because user can create a subclass of every AST class.
msg372438 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-06-26 18:11
> Where they were identifable in such way? It is incorrect way, because user can create a subclass of every AST class.

You are right, I didn't consider that while I was opening the issue. Also from 3.9>= can be searched "|" in the ASDL signature to identify these types.
History
Date User Action Args
2020-06-26 18:11:19BTaskayasetstatus: open -> closed
resolution: not a bug
messages: + msg372438

stage: resolved
2020-06-19 08:08:58serhiy.storchakasetmessages: + msg371850
2020-06-18 09:38:01BTaskayacreate