mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[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:
parent
335e3d59e0
commit
69a9f47125
5 changed files with 63 additions and 5 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue