From 5bf22fc7e3c392c8bd44315ca2d06d7dca7d084e Mon Sep 17 00:00:00 2001 From: sotech117 Date: Thu, 31 Jul 2025 17:27:24 -0400 Subject: add code for analysis of data --- venv/lib/python3.8/site-packages/narwhals/_enum.py | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 venv/lib/python3.8/site-packages/narwhals/_enum.py (limited to 'venv/lib/python3.8/site-packages/narwhals/_enum.py') diff --git a/venv/lib/python3.8/site-packages/narwhals/_enum.py b/venv/lib/python3.8/site-packages/narwhals/_enum.py new file mode 100644 index 0000000..929eecc --- /dev/null +++ b/venv/lib/python3.8/site-packages/narwhals/_enum.py @@ -0,0 +1,42 @@ +from __future__ import annotations + +# ruff: noqa: ARG004 +from enum import Enum +from typing import Any + + +class NoAutoEnum(Enum): + """Enum base class that prohibits the use of enum.auto() for value assignment. + + This behavior is achieved by overriding the value generation mechanism. + + Examples: + >>> from enum import auto + >>> from narwhals._enum import NoAutoEnum + >>> + >>> class Colors(NoAutoEnum): + ... RED = 1 + ... GREEN = 2 + >>> Colors.RED + + + >>> class ColorsWithAuto(NoAutoEnum): + ... RED = 1 + ... GREEN = auto() + Traceback (most recent call last): + ... + ValueError: Creating values with `auto()` is not allowed. Please provide a value manually instead. + + Raises: + ValueError: If `auto()` is attempted to be used for any enum member value. + """ + + @staticmethod + def _generate_next_value_( + name: str, start: int, count: int, last_values: list[Any] + ) -> Any: + msg = "Creating values with `auto()` is not allowed. Please provide a value manually instead." + raise ValueError(msg) + + +__all__ = ["NoAutoEnum"] -- cgit v1.2.3-70-g09d2