diff --git a/personal_python_ast_optimizer/parser/config.py b/personal_python_ast_optimizer/parser/config.py index dff5cfb..3b2671e 100644 --- a/personal_python_ast_optimizer/parser/config.py +++ b/personal_python_ast_optimizer/parser/config.py @@ -1,7 +1,12 @@ -from abc import ABC, abstractmethod +from abc import abstractmethod from enum import Enum, EnumType +from types import EllipsisType from typing import Iterable, Iterator +# I tried to import this from ast, it worked on 3.12 but not 3.11? +# TODO: When minimum python becomes 3.12, add "type" before definition +_ConstantValue = str | bytes | bool | int | float | complex | None | EllipsisType + class TokensToSkip(dict[str, int]): @@ -34,7 +39,7 @@ def _set_to_dict_of_counts(input_set: set[str] | None) -> dict[str, int]: return {key: 0 for key in input_set} -class _Config(ABC): +class _Config: __slots__ = () @@ -130,13 +135,13 @@ class OptimizationsConfig(_Config): def __init__( self, - vars_to_fold: dict[str, int | str | bool] | None = None, + vars_to_fold: dict[str, _ConstantValue] | None = None, enums_to_fold: Iterable[EnumType] | None = None, fold_constants: bool = True, remove_unused_imports: bool = True, assume_this_machine: bool = False, ) -> None: - self.vars_to_fold: dict[str, int | str | bool] = ( + self.vars_to_fold: dict[str, _ConstantValue] = ( {} if vars_to_fold is None else vars_to_fold ) self.enums_to_fold: dict[str, dict[str, Enum]] = ( diff --git a/version.txt b/version.txt index ce7f2b4..c0baecb 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -5.2.2 +5.2.3