8000 gh-119933 : Improve ``SyntaxError`` message for invalid type parameters expressions by picnixz · Pull Request #119976 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119933 : Improve SyntaxError message for invalid type parameters expressions #119976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6279686
fix ``SyntaxError`` for invalid type parameters expressions
picnixz Jun 3, 2024
7075bc6
blurb
picnixz Jun 3, 2024
74d330e
improve doc & naming
picnixz Jun 3, 2024
1ff9183
visual improvements of some test
picnixz Jun 3, 2024
234200c
Merge branch 'main' into fix-119933
picnixz Jun 3, 2024
fa7f02f
simplify the flow
picnixz Jun 3, 2024
b77cebb
Merge branch 'main' into fix-119933
picnixz Jun 4, 2024
7482db6
address review
picnixz Jun 4, 2024
2edf665
address review
picnixz Jun 4, 2024
845c7a6
use the same declaration order across files
picnixz Jun 4, 2024
bbfdcb7
Use enumeration members instead of `.value`.
picnixz Jun 5, 2024
f1208c7
export `SymbolTableType` enumeration
picnixz Jun 5, 2024
e533e4d
update NEWS
picnixz Jun 5, 2024
4cf0bf8
simplify `ste_scope_info` creation
picnixz Jun 5, 2024
740c8f2
improve documentation for `TypeVariableBlock`
picnixz Jun 5, 2024
3e329df
update documentation
picnixz Jun 5, 2024
18bc1f3
fixup
picnixz Jun 5, 2024
dd8d461
Merge branch 'main' into fix-119933
picnixz Jun 5, 2024
2ca6fd9
blurb
picnixz Jun 5, 2024
278d1fc
fixup
picnixz Jun 5, 2024
3f6a03e
Merge branch 'main' into fix-119933
picnixz Jun 12, 2024
3667349
Merge branch 'main' into fix-119933
picnixz Jun 12, 2024
82a37b6
Move SyntaxError's NEWS into "Core and Builtins"
picnixz Jun 13, 2024
cf45f40
improve documentation wording
picnixz Jun 13, 2024
e96f6b4
Update Python/symtable.c
picnixz Jun 17, 2024
705a76f
Update Doc/library/symtable.rst
picnixz Jun 17, 2024
abad81b
address review
picnixz Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use the same declaration order across files
  • Loading branch information
picnixz committed Jun 4, 2024
commit 845c7a657cf9e3c9cb78519a0d022f7f9b607c8d
6 changes: 3 additions & 3 deletions Lib/symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class SymbolTableType(StrEnum):
FUNCTION = "function"
CLASS = "class"
ANNOTATION = "annotation"
TYPE_VARIABLE = "type variable"
TYPE_ALIAS = "type alias"
TYPE_PARAMETERS = "type parameters"
TYPE_VARIABLE = "type variable"


class SymbolTable:
Expand Down Expand Up @@ -88,12 +88,12 @@ def get_type(self):
return SymbolTableType.CLASS.value
if self._table.type == _symtable.TYPE_ANNOTATION:
return SymbolTableType.ANNOTATION.value
if self._table.type == _symtable.TYPE_TYPE_VARIABLE:
return SymbolTableType.TYPE_VARIABLE.value
if self._table.type == _symtable.TYPE_TYPE_ALIAS:
return SymbolTableType.TYPE_ALIAS.value
if self._table.type == _symtable.TYPE_TYPE_PARAMETERS:
return SymbolTableType.TYPE_PARAMETERS.value
if self._table.type == _symtable.TYPE_TYPE_VARIABLE:
return SymbolTableType.TYPE_VARIABLE.value
assert False, f"unexpected type: {self._table.type}"

def get_id(self):
Expand Down
4 changes: 2 additions & 2 deletions Modules/symtablemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ symtable_init_constants(PyObject *m)
return -1;
if (PyModule_AddIntConstant(m, "TYPE_ANNOTATION", AnnotationBlock) < 0)
return -1;
if (PyModule_AddIntConstant(m, "TYPE_TYPE_VARIABLE", TypeVariableBlock) < 0)
return -1;
if (PyModule_AddIntConstant(m, "TYPE_TYPE_ALIAS", TypeAliasBlock) < 0)
return -1;
if (PyModule_AddIntConstant(m, "TYPE_TYPE_PARAMETERS", TypeParametersBlock) < 0)
return -1;
if (PyModule_AddIntConstant(m, "TYPE_TYPE_VARIABLE", TypeVariableBlock) < 0)
return -1;

if (PyModule_AddIntMacro(m, LOCAL) < 0) return -1;
if (PyModule_AddIntMacro(m, GLOBAL_EXPLICIT) < 0) return -1;
Expand Down
0