gh-110045: Update symtable module for PEP 695 (#110066)

This commit is contained in:
Jelle Zijlstra 2023-09-28 19:08:04 -07:00 committed by GitHub
parent 2e37a38bcb
commit 7dc2c5093e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 5 deletions

View file

@ -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.