Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions personal_python_ast_optimizer/parser/config.py
Original file line number Diff line number Diff line change
@@ -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]):

Expand Down Expand Up @@ -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__ = ()

Expand Down Expand Up @@ -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]] = (
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.2
5.2.3