5252NON_COPYABLE = ["ctx" , "printer" , "access_info" ]
5353NON_COPYABLE_WITH_ISL_PREFIX = [f"isl_{ i } " for i in NON_COPYABLE ]
5454
55- PYTHON_RESERVED_WORDS = """
56- and del from not while
57- as elif global or with
58- assert else if pass yield
59- break except import print
60- class exec in raise
61- continue finally is return
62- def for lambda try
63- """ .split ()
55+ PYTHON_RESERVED_WORDS = ["and" , "del" , "from" , "not" , "while" , "as" , "elif" , "global" ,
56+ "or" , "with" , "assert" , "else" , "if" , "pass" , "yield" , "break" , "except" , "import" ,
57+ "print" , "class" , "exec" , "in" , "raise" , "continue" , "finally" , "is" , "return" , "def" ,
58+ "for" , "lambda" , "try" ]
6459
6560
6661class Retry (RuntimeError ): # noqa: N818
@@ -86,8 +81,7 @@ def to_py_class(cls: str):
8681 if cls == "int" :
8782 return cls
8883
89- if cls .startswith ("isl_" ):
90- cls = cls [4 :]
84+ cls = cls .removeprefix ("isl_" )
9185
9286 if cls == "ctx" :
9387 return "Context"
@@ -105,9 +99,7 @@ def to_py_class(cls: str):
10599 else :
106100 result += c
107101
108- result = result .replace ("Qpoly" , "QPoly" )
109-
110- return result
102+ return result .replace ("Qpoly" , "QPoly" )
111103
112104
113105# {{{ data model
@@ -503,11 +495,9 @@ def get_preprocessed_header(self, fname: str) -> str:
503495 self .get_header_contents (mh )
504496 for mh in self .macro_headers ]
505497
506- prepro_header = preprocess_with_macros (
498+ return preprocess_with_macros (
507499 macro_header_contents , self .get_header_contents (fname ))
508500
509- return prepro_header
510-
511501 # {{{ read_header
512502
513503 def read_header (self , fname : str ):
@@ -536,11 +526,8 @@ def read_header(self, fname: str):
536526 while i < len (lines ):
537527 line = lines [i ].strip ()
538528
539- if (not line
540- or line .startswith ("extern" )
541- or STRUCT_DECL_RE .search (line )
542- or line .startswith ("typedef" )
543- or line == "}" ):
529+ if (not line or line .startswith (("extern" , "typedef" ))
530+ or STRUCT_DECL_RE .search (line ) or line == "}" ):
544531 i += 1
545532 elif "/*" in line :
546533 while True :
@@ -661,7 +648,7 @@ def parse_decl(self, decl: str):
661648 if name .startswith ("options_" ):
662649 class_name = "ctx"
663650 name = name [len ("options_" ):]
664- elif name .startswith ("equality_" ) or name . startswith ( "inequality_" ):
651+ elif name .startswith (( "equality_" , "inequality_" ) ):
665652 class_name = "constraint"
666653 elif name == "ast_op_type_set_print_name" :
667654 class_name = "printer"
@@ -697,7 +684,7 @@ def parse_decl(self, decl: str):
697684 return
698685
699686 if class_name == "options" :
700- assert name .startswith ("set_" ) or name . startswith ( "get_" ), (name , c_name )
687+ assert name .startswith (( "set_" , "get_" ) ), (name , c_name )
701688 name = f"{ name [:4 ]} option_{ name [4 :]} "
702689
703690 words = return_base_type .split ()
@@ -1497,9 +1484,8 @@ def write_exposer(
14971484 if basic_cls == "basic_set" :
14981485 if meth .name in ["is_params" , "get_hash" ]:
14991486 continue
1500- elif basic_cls == "basic_map" :
1501- if meth .name in ["get_hash" ]:
1502- continue
1487+ elif basic_cls == "basic_map" and meth .name in ["get_hash" ]:
1488+ continue
15031489
15041490 basic_overloads .append (meth )
15051491
0 commit comments