33import os
44import types
55from ast import unparse
6- from collections .abc import Iterable
6+ from collections .abc import Callable , Iterable
77from pathlib import Path
8- from typing import Any , Callable , Optional
8+ from typing import Any
99
1010from basilisp .lang import list as llist
1111from basilisp .lang import map as lmap
@@ -60,7 +60,7 @@ def to_py_str(t: ast.AST) -> str:
6060class CompilerContext :
6161 __slots__ = ("_filename" , "_actx" , "_gctx" , "_optimizer" )
6262
63- def __init__ (self , filename : str , opts : Optional [ CompilerOpts ] = None ):
63+ def __init__ (self , filename : str , opts : CompilerOpts | None = None ):
6464 self ._filename = filename
6565 self ._actx = AnalyzerContext (filename = filename , opts = opts )
6666 self ._gctx = GeneratorContext (filename = filename , opts = opts )
@@ -84,15 +84,15 @@ def py_ast_optimizer(self) -> PythonASTOptimizer:
8484
8585
8686def 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 ,
87+ generate_auto_inlines : bool | None = None ,
88+ inline_functions : bool | None = None ,
89+ warn_on_arity_mismatch : bool | None = None ,
90+ warn_on_shadowed_name : bool | None = None ,
91+ warn_on_shadowed_var : bool | None = None ,
92+ warn_on_unused_names : bool | None = None ,
93+ warn_on_non_dynamic_set : bool | None = None ,
94+ use_var_indirection : bool | None = None ,
95+ warn_on_var_indirection : bool | None = None ,
9696) -> CompilerOpts :
9797 """Return a map of compiler options with defaults applied."""
9898 return lmap .map (
@@ -148,7 +148,7 @@ def compile_and_exec_form(
148148 ctx : CompilerContext ,
149149 ns : runtime .Namespace ,
150150 wrapped_fn_name : str = _DEFAULT_FN ,
151- collect_bytecode : Optional [ BytecodeCollector ] = None ,
151+ collect_bytecode : BytecodeCollector | None = None ,
152152) -> Any :
153153 """Compile and execute the given form. This function will be most useful
154154 for the REPL and testing purposes. Returns the result of the executed expression.
@@ -204,7 +204,7 @@ def _incremental_compile_module(
204204 py_ast : GeneratedPyAST ,
205205 module : BasilispModule ,
206206 source_filename : str ,
207- collect_bytecode : Optional [ BytecodeCollector ] = None ,
207+ collect_bytecode : BytecodeCollector | None = None ,
208208) -> None :
209209 """Incrementally compile a stream of AST nodes in module mod.
210210
@@ -232,7 +232,7 @@ def _bootstrap_module(
232232 gctx : GeneratorContext ,
233233 optimizer : PythonASTOptimizer ,
234234 module : BasilispModule ,
235- collect_bytecode : Optional [ BytecodeCollector ] = None ,
235+ collect_bytecode : BytecodeCollector | None = None ,
236236) -> None :
237237 """Bootstrap a new module with imports and other boilerplate."""
238238 _incremental_compile_module (
@@ -249,7 +249,7 @@ def compile_module(
249249 forms : Iterable [ReaderForm ],
250250 ctx : CompilerContext ,
251251 module : BasilispModule ,
252- collect_bytecode : Optional [ BytecodeCollector ] = None ,
252+ collect_bytecode : BytecodeCollector | None = None ,
253253) -> None :
254254 """Compile an entire Basilisp module into Python bytecode which can be
255255 executed as a Python module.
@@ -298,7 +298,7 @@ def load(
298298 path : str ,
299299 ctx : CompilerContext ,
300300 ns : runtime .Namespace ,
301- collect_bytecode : Optional [ BytecodeCollector ] = None ,
301+ collect_bytecode : BytecodeCollector | None = None ,
302302) -> Any :
303303 """Call :lpy:fn:`basilisp.core/load` with the given ``path``, returning the
304304 result."""
@@ -311,7 +311,7 @@ def load_file(
311311 path : Path ,
312312 ctx : CompilerContext ,
313313 ns : runtime .Namespace ,
314- collect_bytecode : Optional [ BytecodeCollector ] = None ,
314+ collect_bytecode : BytecodeCollector | None = None ,
315315) -> Any :
316316 """Call :lpy:fn:`basilisp.core/load-file` with the given ``path``, returning the
317317 result."""
0 commit comments