summaryrefslogtreecommitdiffstats
path: root/Lib/symtable.py
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2023-09-29 02:08:04 (GMT)
committerGitHub <noreply@github.com>2023-09-29 02:08:04 (GMT)
commit7dc2c5093ef027aab57bca953ac2d6477a4a440b (patch)
treeb0277506d867356ccc983b4abfc4caab59cd5d5d /Lib/symtable.py
parent2e37a38bcbfbe1357436e030538290e7d00b668d (diff)
downloadcpython-7dc2c5093ef027aab57bca953ac2d6477a4a440b.zip
cpython-7dc2c5093ef027aab57bca953ac2d6477a4a440b.tar.gz
cpython-7dc2c5093ef027aab57bca953ac2d6477a4a440b.tar.bz2
gh-110045: Update symtable module for PEP 695 (#110066)
Diffstat (limited to 'Lib/symtable.py')
-rw-r--r--Lib/symtable.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/symtable.py b/Lib/symtable.py
index 5dd71ff..4b0bc6f 100644
--- a/Lib/symtable.py
+++ b/Lib/symtable.py
@@ -62,8 +62,8 @@ class SymbolTable:
def get_type(self):
"""Return the type of the symbol table.
- The values returned are 'class', 'module' and
- 'function'.
+ The values returned are 'class', 'module', 'function',
+ 'annotation', 'TypeVar bound', 'type alias', and 'type parameter'.
"""
if self._table.type == _symtable.TYPE_MODULE:
return "module"
@@ -71,8 +71,15 @@ class SymbolTable:
return "function"
if self._table.type == _symtable.TYPE_CLASS:
return "class"
- assert self._table.type in (1, 2, 3), \
- "unexpected type: {0}".format(self._table.type)
+ if self._table.type == _symtable.TYPE_ANNOTATION:
+ return "annotation"
+ if self._table.type == _symtable.TYPE_TYPE_VAR_BOUND:
+ return "TypeVar bound"
+ if self._table.type == _symtable.TYPE_TYPE_ALIAS:
+ return "type alias"
+ if self._table.type == _symtable.TYPE_TYPE_PARAM:
+ return "type parameter"
+ assert False, f"unexpected type: {self._table.type}"
def get_id(self):
"""Return an identifier for the table.