55from ast import unparse
66from collections .abc import Iterable
77from pathlib import Path
8- from typing import Any , Callable , Optional
8+ from typing import Any , Optional
9+ from collections .abc import Callable
910
1011from basilisp .lang import list as llist
1112from basilisp .lang import map as lmap
@@ -60,7 +61,7 @@ def to_py_str(t: ast.AST) -> str:
6061class CompilerContext :
6162 __slots__ = ("_filename" , "_actx" , "_gctx" , "_optimizer" )
6263
63- def __init__ (self , filename : str , opts : Optional [ CompilerOpts ] = None ):
64+ def __init__ (self , filename : str , opts : CompilerOpts | None = None ):
6465 self ._filename = filename
6566 self ._actx = AnalyzerContext (filename = filename , opts = opts )
6667 self ._gctx = GeneratorContext (filename = filename , opts = opts )
@@ -84,15 +85,15 @@ def py_ast_optimizer(self) -> PythonASTOptimizer:
8485
8586
8687def compiler_opts ( # pylint: disable=too-many-arguments
87- generate_auto_inlines : Optional [ bool ] = None ,
88- inline_functions : Optional [ bool ] = None ,
89- warn_on_arity_mismatch : Optional [ bool ] = None ,
90- warn_on_shadowed_name : Optional [ bool ] = None ,
91- warn_on_shadowed_var : Optional [ bool ] = None ,
92- warn_on_unused_names : Optional [ bool ] = None ,
93- warn_on_non_dynamic_set : Optional [ bool ] = None ,
94- use_var_indirection : Optional [ bool ] = None ,
95- warn_on_var_indirection : Optional [ bool ] = None ,
88+ generate_auto_inlines : bool | None = None ,
89+ inline_functions : bool | None = None ,
90+ warn_on_arity_mismatch : bool | None = None ,
91+ warn_on_shadowed_name : bool | None = None ,
92+ warn_on_shadowed_var : bool | None = None ,
93+ warn_on_unused_names : bool | None = None ,
94+ warn_on_non_dynamic_set : bool | None = None ,
95+ use_var_indirection : bool | None = None ,
96+ warn_on_var_indirection : bool | None = None ,
9697) -> CompilerOpts :
9798 """Return a map of compiler options with defaults applied."""
9899 return lmap .map (
@@ -148,7 +149,7 @@ def compile_and_exec_form(
148149 ctx : CompilerContext ,
149150 ns : runtime .Namespace ,
150151 wrapped_fn_name : str = _DEFAULT_FN ,
151- collect_bytecode : Optional [ BytecodeCollector ] = None ,
152+ collect_bytecode : BytecodeCollector | None = None ,
152153) -> Any :
153154 """Compile and execute the given form. This function will be most useful
154155 for the REPL and testing purposes. Returns the result of the executed expression.
@@ -204,7 +205,7 @@ def _incremental_compile_module(
204205 py_ast : GeneratedPyAST ,
205206 module : BasilispModule ,
206207 source_filename : str ,
207- collect_bytecode : Optional [ BytecodeCollector ] = None ,
208+ collect_bytecode : BytecodeCollector | None = None ,
208209) -> None :
209210 """Incrementally compile a stream of AST nodes in module mod.
210211
@@ -232,7 +233,7 @@ def _bootstrap_module(
232233 gctx : GeneratorContext ,
233234 optimizer : PythonASTOptimizer ,
234235 module : BasilispModule ,
235- collect_bytecode : Optional [ BytecodeCollector ] = None ,
236+ collect_bytecode : BytecodeCollector | None = None ,
236237) -> None :
237238 """Bootstrap a new module with imports and other boilerplate."""
238239 _incremental_compile_module (
@@ -249,7 +250,7 @@ def compile_module(
249250 forms : Iterable [ReaderForm ],
250251 ctx : CompilerContext ,
251252 module : BasilispModule ,
252- collect_bytecode : Optional [ BytecodeCollector ] = None ,
253+ collect_bytecode : BytecodeCollector | None = None ,
253254) -> None :
254255 """Compile an entire Basilisp module into Python bytecode which can be
255256 executed as a Python module.
@@ -298,7 +299,7 @@ def load(
298299 path : str ,
299300 ctx : CompilerContext ,
300301 ns : runtime .Namespace ,
301- collect_bytecode : Optional [ BytecodeCollector ] = None ,
302+ collect_bytecode : BytecodeCollector | None = None ,
302303) -> Any :
303304 """Call :lpy:fn:`basilisp.core/load` with the given ``path``, returning the
304305 result."""
@@ -311,7 +312,7 @@ def load_file(
311312 path : Path ,
312313 ctx : CompilerContext ,
313314 ns : runtime .Namespace ,
314- collect_bytecode : Optional [ BytecodeCollector ] = None ,
315+ collect_bytecode : BytecodeCollector | None = None ,
315316) -> Any :
316317 """Call :lpy:fn:`basilisp.core/load-file` with the given ``path``, returning the
317318 result."""
0 commit comments