[3.12] gh-110045: Update symtable module for PEP 695 (GH-110066) (#110070)

gh-110045: Update symtable module for PEP 695 (GH-110066)
(cherry picked from commit 7dc2c5093e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-09-28 23:10:22 -07:00 committed by GitHub
parent 335e3d59e0
commit 69a9f47125
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.